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只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- Sublime Text3中 less 自动编译成 css 的方法
使用sublime text的less2css插件 步骤: 1.安装node.js,这个到官网下载即可 2.安装less,方法:命令行输入: npm install -g less 3.sublime ...
- golang channle 管道
管道的使用介绍 现在要计算 1-N 的各个数的阶乘,并且把各个数的阶乘放入到 map 中.最后显示出来.要求使用 goroutine 完成 package main import ( "fm ...
- SpringCloud微服务之跨服务调用后端接口
SpringCloud微服务系列博客: SpringCloud微服务之快速搭建EurekaServer:https://blog.csdn.net/egg1996911/article/details ...
- Linux 命令详解(十二)Systemd 入门教程:使用定时器发送邮件(mail)
Systemd 定时器教程:http://www.ruanyifeng.com/blog/2018/03/systemd-timer.html 一.定时任务 Systemd 定时任务:每小时发送一封电 ...
- j2ee应用开发调试工具
j2ee应用程序不能独立运行,需要运行在一个servlet/jsp容器中,常用的servlet/jsp容器如:tomcat,jetty等.在开发调试j2ee程序时,也需要部署在一个指定的容器中.如果每 ...
- 简单回射程序之处理accept返回EINTR错误的服务器程序版本
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <errno.h> ...
- sqlserver二进制存储
CREATE TABLE myTable_yq(Document varbinary(max),yq varchar(20)) --SELECT @xmlFileName = 'c:\TestXml. ...
- STLINK V2安装使用详解
1. 解压st-link_v2_usb driver.zip文件. 2. 运行解压后的st-link_v2_usbdriver.exe文件,安装STLINK V2驱动程序.安装路 ...
- 【bzoj 2002】弹飞绵羊
Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏.游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置 ...
- c文件操作
文件的基本概念 所谓“文件”是指一组相关数据的有序集合. 这个数据集有一个名称,叫做文件名. 实际上在前面的各章中我们已经多次使用了文件, 例如源程序文件.目标文件.可执行文件.库文件 (头文件)等. ...