Educational Codeforces Round 77 (Rated for Div. 2)
A:
尽可能平均然后剩下的平摊
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=2;
int n,m,a,b;
int read(){
char c=getchar();int x=0,f=1;
while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
return x*f;
}
int main()
{
n=read();
while(n--){
ll kk,kkk,res;
a=read(),b=read();
kk=b/a;
kkk=b%a;
b%=a;
res=(a-kkk)*(kk*kk);
res+=kkk*(kk+1)*(kk+1);
printf("%lld\n",res);
}
return 0;
}
B

逆着思维从0开始操作,会发现两边加起来肯定是3*(k+x+y+...),然后在保证下最小的数起码得大于x+y+z...就行
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=2;
ll n,m;
ll a,b;
ll mi;
ll read(){
char c=getchar();ll x=0,f=1;
while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
return x*f;
}
int main()
{
n=read();
while(n--){
a=read(),b=read();
mi=min(a,b);
if((a==1&&b==1)||(a==2&&b==2)){puts("NO");continue;}
ll ans=a+b;
if(ans%3==0){
if((ans/3)>mi){puts("NO");continue;}
else {puts("YES");continue;}
}
else puts("NO");
}
return 0;
}
c
有一个超长围栏
l r
从0开始,第i块板下标是l的倍数,刷红色,是r的倍数,刷蓝色,同时是l,r的倍数,红蓝都可以。
然后有颜色的板子连起来,如果有k个板子的颜色一模一样,你就死定了。
// In God We Trust # include <bits/stdc++.h>
using namespace std; # define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second int gcd(int a, int b)
{
// Everything divides 0
if (a == 0)
return b;
if (b == 0)
return a; // base case
if (a == b)
return a; // a is greater
if (a > b)
return gcd(a % b, b);
return gcd(a, b % a);
} signed main() {
cout<<__gcd(8,12);
int t;
cin >> t;
int r, b, k;
for (int i = 0; i <t; i++){
cin >> r >> b >> k;
if ( r == b ){
cout << "obey" << endl ;
continue;
}
int g = gcd(r, b);
int n = max(r, b) / g;
int m = min(r, b) / g;///简化
int l = n / m;
if (m == 1)///模拟一下就知道为什么
l --;
else if (n % m != 1)///我们可以理解为,n到2n,2n到3n,3n到4n。。。。等于1相当于某一段n的区间内m的倍数接下来下一个数字就是n,之间没有多出一个数字,也就是说如果不等于1,中间空出来几个数字会提供m的倍数几个位置导致在下一段的n区间内,第一个m的倍数字可以前移了,那么肯定是可以再提供一个数字的在此区间里!!
l ++;
if (l < k)
cout << "obey" << endl;
else
cout << "rebel" << endl;
} }
Educational Codeforces Round 77 (Rated for Div. 2)的更多相关文章
- 【cf比赛记录】Educational Codeforces Round 77 (Rated for Div. 2)
比赛传送门 这场题目前三题看得挺舒服的,没有臃肿的题目,对于我这种英语渣渣就非常友好,但因为太急了,wa了两发A后才意识到用模拟(可以删了,博主真的是个菜鸟),结果导致心态大崩 ---- 而且也跟最近 ...
- Educational Codeforces Round 77 (Rated for Div. 2) D A game with traps
题意:x正轴上有着一个陷阱的位置,开关和灵敏度,如果一个士兵灵敏度输给陷阱,他是过不去这个陷阱的幸运的是,你可以先过去把开关给关了,没错你是不怕陷阱的接下来呢你有操作,你移动一个,耗费一秒而你的团队需 ...
- 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) - 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) C. Infinite Fence
C. Infinite Fence 题目大意:给板子涂色,首先板子是顺序的,然后可以涂两种颜色,如果是r的倍数涂成红色,是b的倍数涂成蓝色, 连续的k个相同的颜色则不能完成任务,能完成任务则输出OBE ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
随机推荐
- 【Koa】385- koa框架的快速入门与使用
点击上方"前端自习课"关注,学习起来~ 简介 Koa 是一个新的 web 框架,由 Express 幕后的原班人马打造, 致力于成为 web 应用和 API 开发领域中的一个更小. ...
- 【Seleniuem】selenium.common.exceptions.InvalidSelectorException
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: An invalid or illega ...
- 9月腾讯、百度、阿里高频的29道SSM框架面试题解析
一.Spring面试题 1.Spring 在ssm中起什么作用? Spring:轻量级框架 作用:Bean工厂,用来管理Bean的生命周期和框架集成. 两大核心:1.IOC/DI(控制反转/依赖注入) ...
- spring data jpa 操作pipelinedb 的continuous view 与stream
一. 由于pipelinedb是postgreSQL的扩展,因此相关依赖于配置都合集成postgreSQL是一样的. springboot + spring data jpa + postgreSQL ...
- 发布一个基于协程和事件循环的c++网络库
目录 介绍 使用 性能 实现 日志库 协程 协程调度 定时器 Hook RPC实现 项目地址:https://github.com/gatsbyd/melon 介绍 开发服务端程序的一个基本任务是处理 ...
- THLM,CSS
目录 HTTP协议的四大特性 数据格式 状态码 HTML概念 标签 标签分类 按是否封闭分类 按级别分类 标签属性 head内常用标签 body内常用标签 body内重要标签 a 标签 img 标签 ...
- 深入理解 Spring Cloud 核心组件与底层原理
一.Spring Cloud核心组件:Eureka Netflix Eureka Eureka详解 1.服务提供者 2.服务消费者 3.服务注册中心 二.Spring Cloud核心组件:Ribbon ...
- 《Netty Zookeeper Redis 高并发实战》 图书简介
<Netty Zookeeper Redis 高并发实战> 图书简介 本书为 高并发社群 -- 疯狂创客圈 倾力编著, 高度剖析底层原理,深度解读面试难题 疯狂创客圈 Java 高并发[ ...
- 2019前端面试系列——CSS面试题
盒模型 /* 红色区域的大小是多少?200 - 20*2 - 20*2 = 120 */ .box { width: 200px; height: 200px; padding: 20px; marg ...
- 求连通块个数 - BFS、DFS、并查集实现
本文基于leetcode的200.岛屿数量(题目