点击题号进入题面

---------

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

------

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 模块二(os,json,pickle)

    #################################总结##################### os常用 os.makedirs('baby/安哥拉/特斯拉/黄晓明') os.mkd ...

  2. Linux记录-lsof打开文件工具常用操作

    lsof `which httpd` //那个进程在使用apache的可执行文件 lsof /etc/passwd //那个进程在占用/etc/passwd lsof /dev/hda6 //那个进程 ...

  3. vim学习之改头换面(基础配置)

    还记得在线有个维护博客园的学长说过,这网站的前端做的贼丑,今日一看果真如此.其实我想说毕竟干货多,没有那么多花花肠子.下面开始进入正题. 在入坑了sublime.vscode.atom.notepad ...

  4. 微信小程序开发(2) 计算器

    在这篇微信小程序开发教程中,我们将介绍如何使用微信小程序开发计算器功能. 本文主要分为两个部分,小程序主体部分及计算器业务页面部分 一.小程序主体部分 一个小程序主体部分由三个文件组成,必须放在项目的 ...

  5. sql server 2008 windows验证改混合登陆中SqlServer身份验证用户名密码

    安装过程中,SQL Server 数据库引擎设置为 Windows 身份验证模式或 SQL Server 和 Windows 身份验证模式.本主题介绍如何在安装后更改安全模式. 如果在安装过程中选择“ ...

  6. ES6走一波 变量结构赋值

    Destructuring  变量的解构赋值 是一种模式匹配 ES6我关注点之一是用途  能否举些好例子是检验学习到位的方法之一 交换变量值 函数返回多个值 函数入参为对象.数组,内部使用更简洁 意义 ...

  7. struts基础3-把数据写入页面

    一.OGNL(Object-Groph Navigation Language) 是一种强大的表达式语言,可以存取对象的任意属性,调用对象的方法,遍历整个对象的结构图,实现字段类型转化等功能. 1)与 ...

  8. Css/Js推荐类库

    animate.css https://daneden.github.io/animate.css WOW.js http://mynameismatthieu.com/WOW owl.carouse ...

  9. 课程8:《Maven精品教程视频》--视频目录

    2017年3月18日 老师讲的课程 \day01视频\01maven依赖管理.avi; \day01视频\02maven项目构建.avi; \day01视频\03maven程序安装.avi; \day ...

  10. Java学习过程中要记录的地方--汇总

    1.Map的子类 HashMap 是哈希表,根据哈希算法来存的,取出来不一定是按照原来的循序: Ctrl+T 可以看到 HashMap下面有 LinkHashMap 是线性实现的,里面有顺序. --- ...