点击题号进入题面

---------

新笔记本终于到了,可以愉快的写代码了..

------

A 807A

题意:

  给一个codeforces比赛的final standing和比赛前后的rating值,保证不存在一样的rating,

  问你是否能知道本场比赛是否计分,如果不能判断则输出maybe

分析:

  遍历即可

  有人变化直接输出rated,无人变化如果不是顺序则unrated,否则maybe

 /**********************
*@Name:
*
*@Author: Nervending
*@Describtion:
*@DateTime: 2018-02-04 03:39:20
***********************/
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
const int INF=0x3f3f3f3f;
int n;
int a[maxn];
int b[maxn];
int c[maxn];
int cmp(int a,int b){
return a>b;
}
int main(){
//#define test
#ifdef test
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
cin>>n;
for(int i=;i<n;i++){
cin>>a[i]>>b[i];
c[i]=a[i];
}
sort(c,c+n,cmp);
for(int i=;i<n;i++){
if(a[i]!=b[i]){
cout<<"rated";
return ;
}
}
for(int i=;i<n;i++){
if(a[i]>a[i-]){
cout<<"unrated";
return ;
}
}
cout<<"maybe"; #ifdef test
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return ;
}

------

B 807B

题意:

  在一场CF比赛中,需要至少达到y分,当前以及获得足够的x分,x>=y

  除此之外,为了获得奖品,你需要改变自己的分数使得当前分数x经过下列伪代码获得的名次值中存在你的当前名次a

  通过hack的成功和失败可以改变自己的分数x,成功加100失败减50

  求最小的成功次数,输入保证有解

i := (s div 50) mod 475
repeat 25 times:
i := (i * 96 + 42) mod 475
print (26 + i)

分析:

  枚举即可

  先尝试只失败不成功

  然后尝试成功,每次测试也尝试额外失败一次的情况

 /**********************
*@Name:
*
*@Author: Nervending
*@Describtion:
*@DateTime: 06/02/18 22:05
***********************/
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
const int maxm=1e6+;
const int INF=0x3f3f3f3f;
#define show(x) cout<<#x<<"="<<x<< endl
int a,x,y;
int check(int s){
int na=(s/)%;
for(int i=;i<;i++){
na=(na*+)%;
if(a==na+)return true;
}
return false;
} int main() {
//#define test
#ifdef test
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
cin>>a>>x>>y;
for(int i=x;i>=y;i-=){
if(check(i)){
cout<<;
return ;
}
}
for(int i=x+,j=;;j++,i+=){
if(check(i)||check(i-)){
cout<<j;
return ;
}
} #ifdef test
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return ;
}

-------

C 807C

题意;

  你当前的成功次数是x,总次数是y,你希望比值达到a/b,求最小的尝试次数,不存在输出-1

分析:

  可以发现,只需要总次数达到b的整数倍即可,最小的合法倍数必然为解

  成功次数只要为正值且小于总次数即可

  二分枚举倍数即可以获得答案

  注意是可能不存在解的,比如a==b而x!=y,或者a==0而x!=0,可以预先剪枝

 /**********************
*@Name:
*
*@Author: Nervending
*@Describtion:
*@DateTime:
***********************/
#include <bits/stdc++.h>
#define show(x) cout<<#x<<"="<<x<<endl
using namespace std;
const int maxn=1e5+;
const int maxm=1e6+;
const int INF=0x3f3f3f3f;
typedef long long ll;
typedef unsigned long long ull;
inline long long gcd(long long a,long long b){while(b)b=(a%b)+(a=b)-b;return a;}
inline long long lcm(long long a,long long b){return a*b/gcd(a,b);}
ll casn,n,m,k;
ll a,b,x,y; int main(){
//#define test
#ifdef test
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif cin>>casn;
while(casn--){
cin>>x>>y>>a>>b;
if((a==b&&x!=y)||(a==&&x!=)){
cout<<-<<endl;
continue;
}
ll ans=-;
ll l=,r=1e10;
while(l<=r){
ll mid=(l+r)>>;
ll ac=mid*a;
ll at=mid*b;
if(ac>=x&&at>=y&&ac-x<=at-y){
ans=at-y;
r=mid-;
}else {
l=mid+;
}
}
if(ans==-)cout<<-<<endl;
else cout<<ans<<endl;
} #ifdef test
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return ;
}

codeforces 412div.2的更多相关文章

  1. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  2. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  3. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  4. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  5. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  6. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  7. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  8. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

  9. CodeForces - 148D Bag of mice

    http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...

随机推荐

  1. python mysql索引 优化神器explain 慢查询

    ##############总结########## 数据库中专门帮助用户快速找到数据的一种数据结构 类似于字典的目录的索引 索引的作用:约束和加速查找 工作原理: b+树形结构 最上层是树根,中间是 ...

  2. Linux 检查 外部设备 是否存在

    以 USB 为例,如果移植了udev,那么在usb插入的时候,/dev下面会出现usb有关的设备,同时,自动挂载到文件系统的某个节点 如果以文件系统usb对应的挂载点来检测USB是否插入,是不够严谨的 ...

  3. keytool导入导出多条目对比【原】

    步骤一:生成orange.keystore和banana.keystore keytool -genkey -alias orange -keyalg RSA -keysize 1024 -keypa ...

  4. 【leetcode-69】 x 的平方根

    (主要是越界问题) 实现 int sqrt(int x) 函数. 计算并返回 x 的平方根,其中 x 是非负整数. 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去. 示例 1: 输入: 4 ...

  5. ACM-ICPC 2018 南京赛区网络预赛 I Skr (马拉车+hash去重)或(回文树)

    https://nanti.jisuanke.com/t/30998 题意 给一串由0..9组成的数字字符串,求所有不同回文串的权值和.比如说“1121”这个串中有“1”,“2”,“11”,“121” ...

  6. bzoj千题计划324:bzoj5249: [2018多省省队联测]IIIDX(线段树)

    https://www.lydsy.com/JudgeOnline/problem.php?id=5249 把树建出来 如果所有的d互不相同,后续遍历即可 现在有的d相同 将d从小到大排序,考虑如何将 ...

  7. HDU 1006(时钟指针转角 **)

    题意是说求出在一天中时针.分针.秒针之间距离均在 D 度以上的时间占比. 由于三针始终都在转动,所以要分别求出各个针之间的相对角速度,分别求出三针满足角度差的首次时间,再分别求出不满足角度差的最终时间 ...

  8. js监听键盘事件

    用JS监听键盘按下事件(keydown event)   1.监听全局键盘按下事件,例如监听全局回车事件 1 $(document).keydown(function(event){ 2 if(eve ...

  9. Spring Boot中使用使用Spring Security和JWT

     目标 1.Token鉴权 2.Restful API 3.Spring Security+JWT 开始 自行新建Spring Boot工程 引入相关依赖 <dependency> < ...

  10. 解析ArcGis的标注(一)——先看看分数式、假分数式标注是怎样实现的

    该“标注”系列博文的标注引擎使用“标准标注引擎(standard label engine)”,这个概念如不知道,可不理会,ArcGis默认标注引擎就是它. ArcGis的标注表达式支持VBScrip ...