比赛传送门

这场题目前三题看得挺舒服的,没有臃肿的题目,对于我这种英语渣渣就非常友好,但因为太急了,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)的更多相关文章

  1. 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]$表示陷阱的位置,如果你 ...

  2. Educational Codeforces Round 77 (Rated for Div. 2) D A game with traps

    题意:x正轴上有着一个陷阱的位置,开关和灵敏度,如果一个士兵灵敏度输给陷阱,他是过不去这个陷阱的幸运的是,你可以先过去把开关给关了,没错你是不怕陷阱的接下来呢你有操作,你移动一个,耗费一秒而你的团队需 ...

  3. Educational Codeforces Round 77 (Rated for Div. 2)

    A: 尽可能平均然后剩下的平摊 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int ...

  4. 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 ...

  5. Educational Codeforces Round 77 (Rated for Div. 2)D(二分+贪心)

    这题二分下界是0,所以二分写法和以往略有不同,注意考虑所有区间,并且不要死循环... #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> ...

  6. Educational Codeforces Round 77 (Rated for Div. 2) C. Infinite Fence

    C. Infinite Fence 题目大意:给板子涂色,首先板子是顺序的,然后可以涂两种颜色,如果是r的倍数涂成红色,是b的倍数涂成蓝色, 连续的k个相同的颜色则不能完成任务,能完成任务则输出OBE ...

  7. Educational Codeforces Round 53 (Rated for Div. 2) (前五题题解)

    这场比赛没有打,后来补了一下,第五题数位dp好不容易才搞出来(我太菜啊). 比赛传送门:http://codeforces.com/contest/1073 A. Diverse Substring ...

  8. Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code

    Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code 题目链接 题意: 给出\(n\)个俄罗斯套娃,每个套娃都有一个\( ...

  9. Educational Codeforces Round 65 (Rated for Div. 2)题解

    Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...

随机推荐

  1. [sonarqube的使用] sonarlint在idea&eclipse中安装与使用

    介绍 ​ 代码质量管理的开源平台,用于管理源代码的质量 通过插件形式,可以支持包括java,C#,C/C++,PL/SQL,Cobol,JavaScrip,Groovy等等二十几种编程语言的代码质量管 ...

  2. Java程序使用Alpine Linux报错java.lang.NoClassDefFoundError: Could not initialize class org.xerial.snappy.Snappy解决

    报错内容 Caused by: java.lang.UnsatisfiedLinkError: /tmp/snappy-1.1.7-4a4b576a-c34c-481e-b6ac-9b4abacb11 ...

  3. Bootstrap导航栏示例

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  4. 纯C语言实现线性表

    #include <stdio.h> #include <stdlib.h> #define MAXSIZE 100 typedef int ElemType; typedef ...

  5. Mybatis映射文件标签(关于sql)

    Mybatis映射文件 1.接口的全限定名和映射文件的namespace一致 <mapper namespace="com.offcn.dao.UserDao"> 2. ...

  6. Maven项目配置Logback输出JSON格式日志

    最近,项目提出需求,日志需要固定输出为JSON格式,以便后端Flink程序解析. 项目背景 项目为简单的Maven项目,日志由Filebeat采集,因此不需要配置输出至Logstash. 下面为pom ...

  7. NioCopy文件

    步骤: 1.创建输入输出流  fis fos 2.创建通道  fis.getchannel()  fos.getchannel(); 3.创建缓存区      ByteBuffer buffer = ...

  8. Linux shell for循环结构

    Linux Shell   for循环结构 循环结构            1:循环开始条件      2:循环操作      3:循环终止的条件 shell语言          for,while ...

  9. Linux的web服务的介绍

    web(World Wide Web)即全球广域网,也称为万维网,它是一种基于超文本和HTTP的.全球性的.动态交互的.跨平台的分布式图形信息系统.是建立在Internet上的一种网络服务,为浏览者在 ...

  10. Springboot环境搭建_第一个例子

    首先创建一个maven项目 maven项目创建完成之后,找到pom.xml配置节点.需要springboot-starter-web ,springboot-starter-test,springbo ...