codeforces 412div.2
| A | CodeForces 807A | Is it rated? | ||
| B | CodeForces 807B | T-Shirt Hunt | ||
| C | CodeForces 807C | Success Rate | ||
| D | CodeForces 807D | Dynamic Problem Scoring | ||
| E | CodeForces 807E | Prairie Partition |
点击题号进入题面
---------
新笔记本终于到了,可以愉快的写代码了..
------
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的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- 【1】【leetcode-79】 单词搜索
(典型dfs,知道思想写错) 给定一个二维网格和一个单词,找出该单词是否存在于网格中. 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格.同一个单 ...
- HDU 1028(数字拆分 分治)
题意是求所给的数能够被拆分成的不同组合数目. 方法有三种: 一.完全背包. 限制条件:所用数字不大于 n. 目标:求分解种数(组合出 n 的方法数). 令 dp[ i ][ j ] = x 表示 用前 ...
- [Android] Android RxBus 用法学习总结
事件总线的好处在于方便组件之间的交互,RxBus不是一个库,而是使用RxJava实现事件总线的一种思想. rxbus和eventbus相比较: RxJava 主要做异步.网络的数据处理,强大之处就是对 ...
- [Android] Android Butterknife 8.8.1 在 Activity 和 Fragment 、 Adapter 中的使用
ButterKnife是一个专注于Android系统的View注入框架,以前总是要写很多findViewById来找到View对象,有了ButterKnife可以很轻松的省去这些步骤.是大神JakeW ...
- CRM项目之RBAC权限组件-day26
写在前面 上课第26天,打卡: 世间安得双全法 不负如来不负卿 s17day26 CRM项目 项目概要:XX公司CRM - 权限管理,公共组件,app ***** - 熟悉增删改查,Low *** - ...
- HTTP status constants
HTTP status constants value = ngx.HTTP_CONTINUE (100) (first added in the v0.9.20 release) value = n ...
- SpringBoot系列: Actuator监控
Sprng Boot 2 actuator变动加大, 网上很多资料都都已经过期. ============================配置项============================ ...
- centos6.5配置redis服务 很好用谢谢
1.下载Redis3.2.5安装包 wget http://download.redis.io/releases/redis-3.2.5.tar.gz 2.解压.编译. ...
- (5)top k大的数目
一.问题 在一个很长的数组中,求出top k大小的数目 二.办法 用优先队列 时间复杂度O(nlog(k)),应该是最差的情况下是这个 三.Code package algorithm; import ...
- python中矩阵的用法
python矩阵的表示真是让人头大,下面记录一下具体用法:array是numpy库里的.不管怎样, 一.首先导入 numpy: 1)import numpy 2)from numpy import * ...