【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 ...
随机推荐
- [转帖]SQL Server DBCC命令大全
SQL Server DBCC命令大全 原文出处:https://www.cnblogs.com/lyhabc/archive/2013/01/19/2867174.html DBCC DROPC ...
- 在Button样式中添加EventSetter,理解路由事件
XML <Window.Resources> <Style x:Key="ButtonStyle2" TargetType="{x:Type Butto ...
- ElasticSearch6.3.2 集群做节点冷(warm) 热(hot) 分离
拿一个小规模的5节点ES集群做冷热分离尝试,它上面已经有60多个索引,有些索引按月.每月生成一个索引,随着数据的不断写入,历史数据(只需保留三个月数据,三个月之前的数据视为历史数据)越来越占磁盘空间和 ...
- Java : JavaWeb和Tomcat相关
部署:1.直接把项目移动到webapps文件夹下, 用文件夹名访问(如果ROOT文件夹可以直接访问)2.也可以把war包放到webapps文件夹下, tomcat自动解压,但是删除war包必须要停止t ...
- 关于toLocaleString(), toString(), valueOf()方法的使用
所有对象都是具有toLocalString(), toString(), valueOf()三种方法的,此篇博客主要是讲述其在Array引用类型上的使用. 基本使用 调用valueOf()返回的是数组 ...
- lombok的@Accessors注解3个属性说明
https://www.cnblogs.com/kelelipeng/p/11326936.html https://www.cnblogs.com/kelelipeng/p/11326621.htm ...
- 构建简单Windows Service示例
示例源码:WindowsServiceSample ServiceHelper源码:ServiceHelper 1. 创建Windows Service项目,如图: 2. 配置服务参数 3. 安装,启 ...
- Linq分批次,每组1000条
/// <summary> /// 分组插入每次插入1000 /// </summary> /// <param name="data">< ...
- SQL 去重 DISTINCT 语法
SQL SELECT DISTINCT语句 在表中可能会包含重复值.这并不成问题, 不过有时你也许希望仅仅列出不同(distinct)的值. 关键词DISTINCT 用于返回唯一不同的值 语法 SEL ...
- 脱离Office约束,C#结合Mpxj组件完美解析MSProject(.mpp)文件
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...