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. 关于Windows下的访问控制模型

    在探索Windows操作系统的过程中,发现很多有意思 的东西. Windows下的访问控制模型也是我在Github上浏览代码时,无意中发现的. 项目地址 https://github.com/Krut ...

  2. iOS - 图片模糊效果实现

    下面给大家介绍图片模糊效果的三种方法 第一种使用Core Image进行模糊 - (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFl ...

  3. Topics in CS(difference between compile and interpret)

    编译 Compile:把整个程序源代码翻译成另外一种代码,然后等待被执行,发生在运行之前,产物是「另一份代码」. 解释 Interpret:把程序源代码一行一行的读懂然后执行,发生在运行时,产物是「运 ...

  4. Qt QPushButton 背景色

    正常状态:黑底(背景色),白字(前景色),圆角,向外凸起 鼠标停留:背景和前景反色 鼠标按下:背景色变为淡蓝色,向内凹陷 ui->pushButton->setStyleSheet(&qu ...

  5. sysfs和kobject

    sysfs文件系统: sysfs是2.6内核的一个特性,它允许内核代码经由一个in-memory的文件系统把信息出报(export)到用户进程中. 在设备模型中,sysfs文件系统用来表示设备的结构. ...

  6. Eclipse上安装websphere

    Eclipse上安装websphere 参考:https://blog.csdn.net/qq_26264237/article/details/90107508 安装websphere插件 WebS ...

  7. Redis for C#

    ServiceStack.Redis 初识Redis时接触到的.Net-Redis组件是 ServiceStack.Redis,其V3系列的最新版本是:ServiceStack.Redis.3.9.2 ...

  8. Python_逻辑运算符

    1.逻辑运算符

  9. 【OF框架】使用OF框架创建应用项目

    开始:准备工作 开发环境已经安装Visual Studio,包含Web开发负载.Python开发负载.NodeJs开发负载 开发环境已经安装Visual Studio Code 开发环境已经安装Nod ...

  10. 二叉树遍历(非递归版)——python

    二叉树的遍历分为广度优先遍历和深度优先遍历 广度优先遍历(breadth first traversal):又称层次遍历,从树的根节点(root)开始,从上到下从从左到右遍历整个树的节点. 深度优先遍 ...