【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 ...
随机推荐
- C# SqlServer Ado.net参数化查询插入null数据
DateTime? dt=null; if (dt.HasValue) { cmd.Parameters.AddWithValue("@CreateDateTime", dt); ...
- Android 支持库迁移到AndroidX
一.背景 Android系统版本在不断更新,从最初的Android 1.0到现在Google和各大手机厂商正在推的Android 10,平均下来每个年头都有一个大的版本更新.但用户正在用的手机上的An ...
- mysql判断是否存在数据库和表,进行删除和创建
1.存在莫数据库,则删除创建一个新库 drop database if exists `tpm_business`; CREATE DATABASE tpm_business DEFAULT CHAR ...
- .NetCore使用NLog写入数据库总结
考虑到项目后期添加日志的需求,抽个闲暇时间学习一下使用NLog插件将日志信息写入到数据库中,完整项目见下面: 遇到的问题: 使用NLog写到SQLServer里面的中文显示问号? 解决方法:调整数据库 ...
- GitHub 上受欢迎的 Android UI Library整理
https://github.com/Tapadoo/Alerter ★2528 - 克服Toast和Snackbar的限制 https://github.com/wenmingvs/NotifyUt ...
- CLOS : Common Lisp 的面向对象支持
1. defclass ( :accessor/reader/writer ; :initarg ; :initform 2. defgeneric 3. defmethod ----- ...
- golang下载图片,而非预览
1 前言 网上查询使用html5,a增加属性download和使用表单get,post提交,都是只能预览,根本原因是返回值需要加入头 w.Header().Add("Content-Type ...
- Java之路---Day17(数据结构)
2019-11-04-23:03:13 目录: 1.常用的数据结构 2.栈 3.队列 4.数组 5.链表 6.红黑树 常用的数据结构: 包含:栈.队列.数组.链表和红黑树 栈: 栈:stack,又称堆 ...
- ArrayList集合的
import java.util.ArrayList; /* * 如果想向集合ArrayList中存储基本数据类型,必须使用基本数据类型的“包装类” * * 基本类型 包装类(引用类型,包装类型都位于 ...
- Python——EM(期望极大算法)教学(附详细代码与注解)
今天,我们详细的讲一下EM算法. 前提准备 Jupyter notebook 或 Pycharm 火狐浏览器或谷歌浏览器 win7或win10电脑一台 网盘提取csv数据 需求分析 实现高斯混合模型的 ...