Good Bye 2018题解

题解 CF1091A 【New Year and the Christmas Ornament】

打完cf都忘记写题解了qwq

题意就是:给你一些黄,蓝,红的球,满足蓝的数量恰比黄的多一,红的数量恰比蓝的多一

容易发现黄的数量恰是\(\min{y,b-1,r-2}\)

输出这个值\(*3+3\)即可

# include <bits/stdc++.h>

int main()
{
int y, b, r;
scanf("%d%d%d", &y, &b, &r);
int ans = std::min(std::min(y, b - 1), r - 2);
printf("%d\n", ans * 3 + 3);
return 0;
}

题解 CF1091B 【New Year and the Treasure Geolocation】

打cf时网速感人qwq

容易想到一个\(O(n^3)\)的做法:枚举每一对\((x,y)\)与每一对\((a,b)\)配对,再判断是否满足条件,满足就输出

但是这样会超时,怎么办?

可以发现我们只要把每一个\((x,y)\)与第一个\((a,b)​\)配对即可

原因?因为每一对\((x,y)\)与每一对\((a,b)\)配对都要导致第一个\((a,b)\)与某一个\((x,y)\)配对,而任意一对这样的配对即可唯一确定\(T\)的位置,故只要枚举一遍每一个\((x,y)\)与第一个\((a,b)\)配对就能遍历所有情况。

时间复杂度\(O(n^2)\)

# include <bits/stdc++.h>
# define p std::pair<int, int> p pos[1010], change[1010]; std::map<p, int> m, tmp; int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d%d", &pos[i].first, &pos[i].second);
for(int i = 1; i <= n; i++)
scanf("%d%d", &change[i].first, &change[i].second), m[change[i]]++;
for(int i = 1; i <= n; i++)
{
p T;
T.first = pos[i].first + change[1].first;
T.second = pos[i].second + change[1].second;
tmp = m;
int flag = true;
for(int j = 1; j <= n; j++)
{
p tem;
tem.first = T.first - pos[j].first;
tem.second = T.second - pos[j].second;
if(!tmp[tem])
flag = false;
--tmp[tem];
}
if(flag)
return 0 * printf("%d %d\n", T.first, T.second);
}
return 0;
}

题解 CF1091C 【New Year and the Sphere Transmission】

这个C真烧脑qwq

可以发现每一次选的数的个数都是\(n\)的约数

枚举所有约数,计算答案即可(等差数列求和好评!)

#include <bits/stdc++.h>
#define ll long long
std::vector<ll> v, ans;
void prime(ll n)
{
for (int i = 1; i * i <= n; ++i)
{
if (n % i == 0)
{
v.push_back(i);
if (i * i != n)
{
v.push_back(n / i);
}
}
}
}
std::map<ll, int> m;
int main()
{
ll n;
scanf("%I64d", &n);
prime(n);
for (int i = 0; i < v.size(); i++)
{
m[v[i]] = 1;
}
for(std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++)
{
ll x = n / it->first;
ans.push_back((1 + (x * (it->first - 1) + 1)) * (it->first) / 2);
}
std::sort(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i++)
printf("%I64d\n", ans[i]);
return 0;
}

Good Bye 2018题解的更多相关文章

  1. Codeforces:Good Bye 2018(题解)

    Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...

  2. Good Bye 2018 (A~F, H)

    目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.N ...

  3. WC 2018 题解

    WC 2018 题解 一些感受.jpg 题目难度相较前些年会相对简单一点?(FAKE.jpg 平均码量符合WC风格?(甚至更多一点 出题人良心! [WC2018] 通道 一个不知道对不对的$\log ...

  4. Good Bye 2018

    Good Bye 2018 2018年最后一场CF,OVER! 弱弱的我只能做出3道A,B,D~~~~ 最后几分钟,感觉找到了C题的规律,结束的那一刻,提交了一发 "Wrong answer ...

  5. Codeforces Good Bye 2018

    咕bye 2018,因为我这场又咕咕咕了 无谓地感慨一句:时间过得真快啊(有毒 A.New Year and the Christmas Ornament 分类讨论后等差数列求和 又在凑字数了 #in ...

  6. PKUSC 2018 题解

    PKUSC 2018 题解 Day 1 T1 真实排名 Link Solution 考虑对于每一个人单独算 每一个人有两种情况,翻倍和不翻倍,他的名次不变等价于大于等于他的人数不变 设当前考虑的人的成 ...

  7. Codeforces Good Bye 2016 题解

    好久没有fst题了...比赛先A了前4题然后发现room里有人已经X完题了没办法只能去打E题,结果差一点点打完...然后C题fst掉了结果就掉rating 了...下面放题解 ### [A. New ...

  8. Good Bye 2018 D. New Year and the Permutation Concatenation

    传送门 https://www.cnblogs.com/violet-acmer/p/10201535.html 题意: 求 n 的所有全排列组成的序列中连续的 n 个数加和为 n*(n+1)/2 的 ...

  9. Good Bye 2018 C. New Year and the Sphere Transmission

    传送门 https://www.cnblogs.com/violet-acmer/p/10201535.html 题意: n 个people,编号1~n,按顺时针方向围城一圈: 初始,编号为1的peo ...

随机推荐

  1. PB数据窗口分页

    第一步:增加一个计算列,此计算列必须放在Detail段,Expression中输入: ceiling(getrow()/500)  --这里500还可以用全局函数取代,这样可以允许用户任意设置每页多少 ...

  2. Itemchanged事件

    Itemchanged事件:当数据窗口控件中某个域被修改并且该域失去输入焦点该事件返回的意义为: 0--(缺省返回值),接收新修改的值: 1--不接收新修改的值且不允许改变输入焦点: 2--不接收新修 ...

  3. PowerShell自动部署ASP.NET Core程序到 IIS

    Windows PowerShell 是一种命令行外壳程序和脚本环境,使命令行用户和脚本编写者可以利用 .NET Framework的强大功能.有关于更多PowerShell的信息,可参阅百度词条 接 ...

  4. 怎样查看python的所有关键字

    关键字是python中具有特定功能的一组词汇, 这些词汇不能用作变量名, 一般会有高亮提示, code时请小心. python的关键字其实也是python的语法核心, 掌握了所有python关键字的用 ...

  5. VsCode开发Angular的必备插件

    1 概述 一般个人开发或者小公司开发都会使用破解版软件,除非比较尊重正版且不太缺钱的人才会用正版,但是大型公司有严格的规定,不允许员工使用盗版软件. 这时候我就不得不从WebStorm转向VsCode ...

  6. pdm文件打开方式

    转自:https://blog.csdn.net/qq_36855191/article/details/79299216 pdm打开网站:http://www.dmanywhere.cn/

  7. English-培训3-Please call me Beth

  8. NLP使用pytorch框架,pytorch安装

    pytorch的安装方法及出现问题的解决方案: 安装pytorch,使用pip 安装,在运行代码的时候会报错,但是导包的时候不会报错,因此要采用conda的方式安装   1.找到miniconda的网 ...

  9. Python_赋值运算符

    1.赋值运算符

  10. zookeeper服务【-】windows安装与liunx安装

    windows安装zookeeper-3.4.14 https://www.apache.org/dyn/closer.cgi/zookeeper/ [zookeeper下载地址] 1.开启服务之前需 ...