【cf比赛记录】Educational Codeforces Round 77 (Rated for Div. 2)
这场题目前三题看得挺舒服的,没有臃肿的题目,对于我这种英语渣渣就非常友好,但因为太急了,wa了两发A后才意识到用模拟(可以删了,博主真的是个菜鸟),结果导致心态大崩 ---- 而且也跟最近的生活学习有点关系 ----补了B,跟C题。B题还是有点可惜的,没有做出来。
A
// http://codeforces.com/contest/1260/problem/A
/*
因为可以把 sum 分成 c 份(每份可以用 0 来补充)
所以要想最小,可以直接取接近中间值的数再平方
下面用模拟实现
*/
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int c, sum;
int main()
{
scanf("%d", &n);
while(n--){
scanf("%d %d", &c, &sum);
if(c >= sum){
printf("%d\n", sum);
}
else if(c == 1){
printf("%d\n", sum * sum);
}
else {
int ans = 0;
while(c > 0){
int d = sum / c;
ans += d * d;
c--;
sum -= d;
}
printf("%d\n", ans);
}
}
return 0;
}
B
// http://codeforces.com/contest/1260/problem/B
/*
分析:
若
a = x_1 + x_2 + ... + x_k
则 b = 2 * x_1 + 2 * x_2 + ... + 2 * x_k = 2 * (x_1 + x_2 + ... + x_k) = 2 * a
由此可以看出 ---- 若输出 YES b 的最大值为 2a
所以有条件一 a * 2 >= b ①
a + b = 3 * (x_1 + x_2 + ... + x_k)
可见 (a + b) % 3 == 0 ②
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n, a, b;
int main()
{
scanf("%d", &n);
while(n--){
scanf("%d %d", &a, &b);
if(a > b) swap(a, b); // 保证 b > a
if((a + b) % 3 == 0 && a * 2 >= b) printf("YES\n");
else printf("NO\n");
}
return 0;
}
C
// https://codeforces.com/contest/1260/problem/C
/*
题意:给木板涂色,要求不能有连续 k 块的颜色一样(没有涂色的木板不计入)
知识点 ---- gcd(int, int) 求两数的最大公约数
当 gcd(r, b) == 1 时(即两数互为质数), 当 r b 相近的时候,如果先涂了r,那么下一个就是 b
此时,要检查 r b 二者差距是否过大 ---- 即要符合
(k - 1) * r + 1 >= b 即连续的第 k-1 格上涂的 r 会比前面一格(因为 gcd() == 1)要大于等于 b
所以,对于 gcd(r, b) > 1 时只需要把它们都除以自己的最大公约数就可以互为质数了
注意会爆 int 范围
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL T, r, b, k;
LL gcd(LL a, LL b){
if(b == 0) return a;
else return gcd(b, a % b);
}
int main()
{
scanf("%I64dd", &T);
while(T--){
scanf("%I64d %I64d %I64d", &r, &b, &k);
if(r > b) swap(r, b);
LL d = gcd(b, r);
b /= d; r /= d;
if((k - 1) * r + 1 >= b){
printf("OBEY\n");
}
else printf("REBEL\n");
}
return 0;
}
掉分了

【cf比赛记录】Educational Codeforces Round 77 (Rated for Div. 2)的更多相关文章
- Educational Codeforces Round 77 (Rated for Div. 2) - D. A Game with Traps(二分)
题意:$m$个士兵,每个士兵都有一个灵敏度$a[i]$,起点为$0$,终点为$n + 1$,在路上有$k$个陷阱,每个陷阱有三个属性$l[i],r[i],d[i]$,$l[i]$表示陷阱的位置,如果你 ...
- Educational Codeforces Round 77 (Rated for Div. 2) D A game with traps
题意:x正轴上有着一个陷阱的位置,开关和灵敏度,如果一个士兵灵敏度输给陷阱,他是过不去这个陷阱的幸运的是,你可以先过去把开关给关了,没错你是不怕陷阱的接下来呢你有操作,你移动一个,耗费一秒而你的团队需 ...
- Educational Codeforces Round 77 (Rated for Div. 2)
A: 尽可能平均然后剩下的平摊 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int ...
- Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes
B. Obtain Two Zeroes time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 77 (Rated for Div. 2)D(二分+贪心)
这题二分下界是0,所以二分写法和以往略有不同,注意考虑所有区间,并且不要死循环... #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> ...
- Educational Codeforces Round 77 (Rated for Div. 2) C. Infinite Fence
C. Infinite Fence 题目大意:给板子涂色,首先板子是顺序的,然后可以涂两种颜色,如果是r的倍数涂成红色,是b的倍数涂成蓝色, 连续的k个相同的颜色则不能完成任务,能完成任务则输出OBE ...
- Educational Codeforces Round 53 (Rated for Div. 2) (前五题题解)
这场比赛没有打,后来补了一下,第五题数位dp好不容易才搞出来(我太菜啊). 比赛传送门:http://codeforces.com/contest/1073 A. Diverse Substring ...
- Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code
Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code 题目链接 题意: 给出\(n\)个俄罗斯套娃,每个套娃都有一个\( ...
- Educational Codeforces Round 65 (Rated for Div. 2)题解
Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...
随机推荐
- 优先队列 + 模拟 - HDU 5437 Alisha’s Party
Alisha’s Party Problem's Link Mean: Alisha过生日,有k个朋友来参加聚会,由于空间有限,Alisha每次开门只能让p个人进来,而且带的礼物价值越高就越先进入. ...
- 数据库的dml、ddl和dcl的概念
学过数据库肯定会知道DML.DDL和DCL这三种语言,这种基础概念性的东西是必须要记住的. DML(Data Manipulation Lanaguage,数据操纵语言) DML就是我们经常用到的SE ...
- 前端学习:CSS的学习总结(图解)
前端学习:CSS的学习总结(图解) CSS代码笔记 CSS简介 css的引入方式和书写规范 CSS选择器 CSS属性 CSS盒子模型 CSS的定位
- STMP发送邮件(C#)
记录一下使用SMTP协议发送邮件 public void Mail() { try { System.Net.Mail.SmtpClient client = new System.Net.Mail. ...
- handle句柄
若是你向我问起 Win32 程序设计中印象最深(最坑爹)的一个概念是什么,那么我会毫不犹豫地告诉你——句柄(Handles).究其原因,无论是 MSDN 还是 维基百科,对于“句柄”这个词的解说都显得 ...
- EWS:邮箱的一个开放的接口服务
https://3gstudent.github.io/3gstudent.github.io/Exchange-Web-Service(EWS)%E5%BC%80%E5%8F%91%E6%8C%87 ...
- 我是如何一步步编码完成万仓网ERP系统的(十三)库存 2.加权平均价
https://www.cnblogs.com/smh188/p/11533668.html(我是如何一步步编码完成万仓网ERP系统的(一)系统架构) https://www.cnblogs.com/ ...
- [世预赛] 中国vs关岛,关岛实力有限 国足或许可以赢其10个球,比分预测 10:0,8:0,13:0
[世预赛] 中国vs关岛 开赛时间:2019-10-10 20:00 继5比0大胜马尔代夫之后,国足迎来世预赛40强赛的第二场比赛,再次向世界杯发起冲击.10月10日,国足在广州迎战神秘之旅关岛. 1 ...
- Object::connect: No such slot QWidget::
出现如下错误 Object::connect: No such slot QWidget::readMyCom() in ../untitled/ConversionScreen.cpp:49 解决办 ...
- Android中实现Activity的透明背景效果
实现方式一(使用系统透明样式) 通过配置 Activity 的样式来实现,在 AndroidManifest.xml 找到要实现透明效果的 Activity,在 Activity 的配置中添加如下的代 ...