Good Bye 2018题解
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题解的更多相关文章
- Codeforces:Good Bye 2018(题解)
Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...
- Good Bye 2018 (A~F, H)
目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.N ...
- WC 2018 题解
WC 2018 题解 一些感受.jpg 题目难度相较前些年会相对简单一点?(FAKE.jpg 平均码量符合WC风格?(甚至更多一点 出题人良心! [WC2018] 通道 一个不知道对不对的$\log ...
- Good Bye 2018
Good Bye 2018 2018年最后一场CF,OVER! 弱弱的我只能做出3道A,B,D~~~~ 最后几分钟,感觉找到了C题的规律,结束的那一刻,提交了一发 "Wrong answer ...
- Codeforces Good Bye 2018
咕bye 2018,因为我这场又咕咕咕了 无谓地感慨一句:时间过得真快啊(有毒 A.New Year and the Christmas Ornament 分类讨论后等差数列求和 又在凑字数了 #in ...
- PKUSC 2018 题解
PKUSC 2018 题解 Day 1 T1 真实排名 Link Solution 考虑对于每一个人单独算 每一个人有两种情况,翻倍和不翻倍,他的名次不变等价于大于等于他的人数不变 设当前考虑的人的成 ...
- Codeforces Good Bye 2016 题解
好久没有fst题了...比赛先A了前4题然后发现room里有人已经X完题了没办法只能去打E题,结果差一点点打完...然后C题fst掉了结果就掉rating 了...下面放题解 ### [A. New ...
- 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 的 ...
- 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 ...
随机推荐
- Spring Boot学习随记
由于早年在管理领域耕耘了一段时间,完美错过了Spring的活跃期, 多少对这个经典的技术带有一种遗憾的心态在里面的, 从下面的我的生涯手绘图中大概可以看出来我的经历. 最近由于新介入到了工业数字化领域 ...
- 使用Harbor搭建Docker私有镜像仓库
Harbor介绍:https://goharbor.io/ 前置条件 需要安装了docker和docker-compose 下载Harbor 在harbor下载页(https://github.com ...
- 转 实现类似QQ的窗体停靠
[DllImport("User32.dll")] public static extern bool PtInRect(ref Rectangle Rects, Point lp ...
- Python、PyCharm、Django框架安装
一.下载Python环境 1.1 下载Python环境,以下网址: https://www.python.org/downloads/release/python-373/ 下载安装包: 1.2点击安 ...
- chrome网页中打开exe
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\VMS] @="URL:VMS" "URL Protoco ...
- POJ3255(Roadblocks)--次短路径
点这里看题目 3228K 485MS G++ 2453B 根据题意和测试用例知道这是一个求次短路径的题目.次短路径,就是比最短路径长那么一丢丢的路径,而题中又是要求从一点到指定点的次短路径,果断Dij ...
- TODO-依赖注入与控制反转
交互框架之Actor与Listener的关系 https://www.cnblogs.com/mq0036/p/7473371.html
- JSONObject和URL以及HttpURLConnection的使用
1 将java对象类转成json格式 首先引入依赖jar文件 注意依赖文件的版本号,高版本可能没有对应的类 2 我的实体类中包含内部类注意内部类要public才能被序列化成json格式 import ...
- day14-python之集合函数字符串格式化
1.集合 #!/usr/bin/env python # -*- coding:utf-8 -*- # s=set(['alex','alex','sb']) # print(s) # s=set(' ...
- Idea设置和查看
1.查看激活码有效期 Help->Register