Codeforces Global Round 8
A. C+=
两个数交替相加判断次数。
AC代码:
int n, m;int main()
{int T;sd(T);while (T--){int a, b;sddd(a, b, n);if (a < b)swap(a, b);int ans = 0;bool flag = 0;while (a <= n && b <= n){if (flag)a += b;elseb += a;ans++;flag=!flag;}pd(ans);}return 0;
}
B. Codeforces Subsequences
codeforcescodeforcescodeforces 这样子序列个数是 1101^{10}110
codeforcescodeforcescodeforcescodeforcescodeforcescodeforces 这样子序列个数是 2102^{10}210
codeforcescodeforcescodeforcescodeforcescodeforcescodeforcescodeforcescodeforcescodeforces 这样子序列个数是 3103^{10}310
在构造时尽量让每个字符都重复一遍。
具体操作看代码。
AC代码:
const int N = 5e5 + 50;
string s = "codeforces";
int main()
{ll k;sd(k);vector<int> cnt(10, 1); //包含10个为1的元素ll tot = 1;rep(i, 2, k - 1){rep(j, 0, 9){if (tot < k){tot = tot / cnt[j] * i;cnt[j] = i; //同cnt[j]++}}}rep(i, 0, 9){cout << string(cnt[i], s[i]);}return 0;
}
C. Even Picture
没规定最小,沿着对角线构造。
1 1 0 0 0 0 0
1 1 1 0 0 0 0
0 1 1 0 0 0 0
0 0 1 1 1 0 0
0 0 0 1 1 1 0
0 0 0 0 1 1 1
0 0 0 0 0 1 1
大概这个样子。
AC代码;
const int N = 5e5 + 50;
int n, m, k;
vector<PII> v;
int main()
{int T;sd(n);int ans = 0;v.pb(PII(1, 1));v.pb(PII(1, 2));rep(i, 2, n + 1){v.pb(PII(i, i - 1));v.pb(PII(i, i));v.pb(PII(i, i + 1));}v.pb(PII(n + 2, n + 1));v.pb(PII(n + 2, n + 2));ans = v.size();pd(ans);for (auto i : v)pdd(i.fi, i.se);return 0;
}
D. AND, OR and square sum
题意给出的操作是不影响二进制下每一个 010 101 的总个数。统计二进制下每一位出现的次数
比如:
1351 3 5135
001011101001 011 101001011101
最高位的 111 出现 111 次,中间的 111 出现 111 次最后的 111 出现 333 次
那就是 111001001111 001 001111001001 。
AC代码:
const int N = 5e5 + 50;
int n, m, k;
int a[N];
int cnt[100];void cal(int x)
{rep(j, 0, 20){if (x & (1 << j))cnt[j]++;}
}int main()
{int T;mem(cnt, 0);sd(n);rep(i, 1, n){sd(a[i]);cal(a[i]);}ll ans = 0;rep(i, 1, n){int now = 0;rep(j, 0, 20){if (cnt[j]){now += (1 << j);cnt[j]--;}}ans += 1ll * now * now;}pld(ans);return 0;
}
Codeforces Global Round 8相关推荐
- Codeforces Global Round 1 晕阙记
Codeforces Global Round 1 晕阙记 我做这场比赛的时候晕得要死.做这三道题做太久了,rating涨不起来啊! A 如果愿意的话你可以看做是膜2意义下的运算,写快速幂等各种膜运算 ...
- Codeforces Global Round 3
Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...
- Codeforces Global Round 14 F. Phoenix and Earthquake 思维 + 并查集
传送门 文章目录 题意: 思路: 题意: 给你nnn个点,mmm条边,限制xxx,每个点都有沥青aia_iai,定义合并两个点即两点之间有边且au+av≥xa_u+a_v\ge xau+av≥x ...
- Codeforces Global Round 1
Codeforces Global Round 1 题解:The Editorial of the First Codeforces Global Round A:其实mod 2计算一下就行了 B:删 ...
- 【Codeforces Global Round 23】B. Rebellion
Codeforces Global Round 23中B. Rebellion Codeforces比赛记录 文章目录 题目链接: 一.B. Rebellion 题目意思: 上思路: 总结 B. Re ...
- Codeforces Global Round 4-D. Prime Graph(伯特兰-切比雪夫定理)
题目:Codeforces Global Round 4-D. Prime Graph 题意:给出n(顶点的个数),要求所得图满足: 1.无平行边和自环 2.边的总数是个质数 3.每个点的度(也就是点 ...
- codeforces global round 23
constest :codeforces global round 23 contest time:2022.10.16 contest grade: 2800 contest rating chan ...
- 贪心 ---- Codeforces Global Round 8,B. Codeforces Subsequences[贪心,贪的乘法原理]
题目链接 给出字符串,统计子串(子串字母可以跳跃)是codeforces的数量. 本题要求,给出子串最少数量k,构造字符串s,要求字符串s包含的字母数量最少,输出这个最少的字符串s. 题目要求是至少有 ...
- Codeforces Global Round 21 E. Placing Jinas
Problem - E - Codeforces (Unofficial mirror by Menci) E. Placing Jinas 题目大意:每个点相当于(0,0)到每个点(只能向下和向右走 ...
- Codeforces Global Round 21 C. Fishingprince Plays With Array
https://codeforces.com/contest/1696/problem/C st1=21:57, ed1=22:10 st2=22:25, ed2=null 标签 数组操作 题意 给定 ...
最新文章
- 独家!扒出腾讯新高管余总的真面目!
- pip报 No module named ‘pip‘ 错误
- 开头和结尾标记 在不同系统_写人作文的写作技巧。含思维导图、开头结尾写法及范文分析...
- 授权码模式-获取令牌
- 关于AutoML的一些笔记
- fastJson性能测试
- 20155201 实验四《Java面向对象程序设计》实验报告
- 阴阳师服务器维护更新,阴阳师服务器3月10日维护更新了什么 阴阳师服务器3月10日维护更新一览...
- qq音乐android升级版,QQ音乐Android 4.8更新 温暖私享正版无损好音乐
- 黑盒测试9种常用方法
- cad计算机忘了保存,cad图纸没保存怎么恢复(电脑突然断电,怎么找回未保存的CAD?)...
- CAN总线负载率原理及计算【转】
- Unix 编程三件套环境搭建
- 回复犹豫的实习生——走好脚下,心怀未来
- Adb shell命令直接打开语言设置界面
- 用最短的时间了解一个人
- Windows 11:面子仿苹果,里子反苹果
- 测试发布,无图版~《Windows Phone 7.5本质论》第一章
- 速学堂第四章代码练习题
- PBX俗称:程控交换机