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< ...
随机推荐
- 一位资深程序员面试Python工程师的岗位心得和历程【新手必须】
前言本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理.作者:程序员阿牛说一些面试的心得体会: 1.简历制作我做了两份简历,用两个手机 ...
- 笔记||Python3之再识函数
变量的作用域: 全局变量 ----- 可以在函数内部被引用 局部变量 ----- 函数内部 -- 只能在函数里面使用,在函数外部不能使用 在函数内部修改全局变量:global x 缺省 ...
- 【Java8流】使用学习
[Java8流]使用学习 ============================================= 1.删除子目录及文件 ============================== ...
- IUSEP研修报告
目录 Introduction Alberta - Edmonton University of Alberta IUSEP Schoolwork and Project Principle of F ...
- 推荐使用的派生方法:super().__init__()
""" 推荐使用的派生方法:super().__init__() --super()的属性查找顺序是从当前位置开始找,根据mro列表,当前没有就往上找. super() ...
- 天天动听API
本次分析的是天天动听API,天天动听有一点比较好,就是搜索返回直接有歌曲播放的地址了,并且有无损的音频 搜索歌曲API:http://so.ard.iyyin.com/s/song_with_out? ...
- var和let部分浅析
ES6中新增了let命令,用于声明变量,但所声明的变量只在let命令的代码块内有效. 举个例子: var a = []; for(var i=0;i<10;i++){ a[i] = functi ...
- 《大话设计模式》——简单工厂模式(Python版)
简单工厂模式(Simple Factory Pattern):是通过专门定义一个类来负责创建其他类的实例,被创建的实例通常都具有共同的父类. 例: 使用Python设计一个控制台计算器,要求输入两个数 ...
- 小公举-linux的计算器
1.一个方便的linux计算器,精巧而强大bc 2..进行简单的四则运算 3.连续的四则运算 4.大数运算 5.求次幂和余数 6.如果要执行小数计算呢,需要设置scale=number ,number ...
- javascript对url进行编码和解码
这里总结下JavaScript对URL进行编码和解码的三个方法. 为什么要对URL进行编码和解码 只有[0-9[a-Z] $ - _ . + ! * ' ( ) ,]以及某些保留字,才能不经过编码直接 ...