Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
A. Doggo Recoloring
ps:注意 n == 1
B. Weakened Common Divisor
题解:WCD出现中的数必然是 < a, b >中某个数的公约数。而 < a, b > 的贡献和 a * b 的贡献是等价,所以gcd就好了。
const int N = 150005;struct node {LL sum, x, y; }a[N];LL gcd(LL x, LL y) {return (!y ? x : gcd(y, x % y)); }void ca(LL x) {for (int i = 2; i <= (int)sqrt(x); ++i) if (x % i == 0) {cout << i << endl;return ;}cout << x << endl; }LL n;int main() {sc(n);for (int i = 1; i <= n; ++i) {sc(a[i].x), sc(a[i].y);a[i].sum = a[i].x * a[i].y;}if (n == 1) {cout << a[1].x << endl;return 0;}LL res = gcd(a[1].x, a[2].sum);for (int i = 3; i <= n; ++i) {res = gcd(res, a[i].sum);}if (res != 1) {ca(res);return 0;}res = gcd(a[1].y, a[2].sum);for (int i = 3; i <= n; ++i) {res = gcd(res, a[i].sum);}if (res != 1){ca(res);return 0;}cout << "-1" << endl;return 0;}
C. Plasticine zebra
题解:观察可得,分成几部分考虑,中间的最大值,以及头和尾的拼接。(细节啊啊啊啊啊,没想清楚鲁代码是很危险的!!!!),头部如果是奇数,那么尾部和头部是相反的。
const int N = 150005;string s;int main() {cin >> s;int n = s.size();if (n == 1) {cout << 1 << endl;return 0;}int res = 1, ans = 0;char last = s[0];for (int i = 1; i < n; ++i) {if (last != s[i]) res++;else {upd(ans, res);res = 1;}last = s[i];}if (res) upd(ans, res);last = s[0];int l = 1, r = 1;for (int i = 1; i < n; ++i) {if (last != s[i]) l++;else break;last = s[i];}if (l & 1) {if (last == 'b') last = 'w';else last = 'b';}if (s[n - 1] != last) r = 0;else {for (int i = n - 2; ~i; --i) {if (last != s[i]) r++;else break;last = s[i];}}if ((l != 1 || r != 1) && l + r <= n) {upd(ans, l + r);}cout << ans << endl;return 0; }
转载于:https://www.cnblogs.com/zgglj-com/p/9504505.html
Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)相关推荐
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)切题报告(A-B题)
这是我第二次参加CF比赛,也是第一次写博客,写得不好,望各位大佬海涵. A. Single Wildcard Pattern Matching 原题链接 这道题,这是难到让人无法直视,太水了. 题目大 ...
- CF#504,#505(based on VK Cup 2018 Final)上红记
去年的我这时还是蓝名小哥,然后勉强上了紫. 当时写过一篇上紫记. 我 打cf频率在friends里还是偏高的,大概就是经常打出饱和状态. 1900- 徘徊过几场,2100±徘徊了好几个月,从noip2 ...
- Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 题号 题目 知识点 A Simply Strange Sor ...
- Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) A-F全题解
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 文章目录 A. Simply Strange Sort B. ...
- Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3)
点击打开A题链接 #include<bits/stdc++.h> using namespace std; const int MAX = 105; int n,s;int h[MAX], ...
- Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)B. Primal Sport
Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try ...
- Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)
今天看不下去数电vp一场div2,搞A搞了很长时间,导致后面没有时间写,不过今天补题的时候全是独立补出来的没有看题解 vp3题,补3题 A - Kids Seating 最开始想的是与质数有关,乱七八 ...
- Educational Codeforces Round 99 (Rated for Div. 2)
传送门 Educational Codeforces Round 99 (Rated for Div. 2) A g(x)g(x)g(x) 的值域为 10n,n∈Z10^n,n\in Z10n,n∈Z ...
- Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...
最新文章
- 【Ubuntu】虚拟机VirtualBox安装win7完整步骤
- paddleocr ‘bytes‘ object has no attribute ‘shape‘
- nodejs与npm版本对应表
- npm安装教程 集成npm webpack vue-cli
- iOS 正则表达式判断UITextField是否为全汉字,全字母,全数字,数字和字母
- C++语法:vector的使用
- 2018-2019-2 网络对抗技术 20165202 Exp9 Web安全基础
- Python字典values()方法与示例
- 作者:蓝梦微, 女, 中国人民大学信息学院博士生,CCF学生会员。
- 继爱奇艺之后,腾讯视频、优酷宣布:取消剧集超前点播服务
- nitc免费效益型企业网站php版 后台不能登陆,nitc免费效益型企业网站PHP版
- 非常不错的Solaris文章,适合入门
- 实变函数与泛函分析课本pdf_免费推荐几本实变函数和泛函分析的书
- Mybatis框架与mysql数据库简单应用
- Python网络爬虫与信息提取学习
- windows7无法登陆网络上的计算机,win7电脑网络连接显示感叹号无法上网怎么处理...
- 微信小程序使用echarts
- iOS开发-Please sign in with an app-specific password. You can create one at appleid.apple.com
- 随时随地和个性化——移动互联网
- 使用线程实现电子时钟