Codeforces Round #412
第一题水题,8分钟1a
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f; int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
cin>>n;
int last;
bool maybe=,rate=;
for(int i=;i<n;i++)
{
int a,b;
cin>>a>>b;
if(i==)last=a;
else
{
if(last<a)maybe=;
last=a;
}
if(a!=b)rate=;
}
if(rate)cout<<"rated"<<endl;
else if(!rate&&maybe)cout<<"unrated"<<endl;
else if(!rate&&!maybe)cout<<"maybe"<<endl;
return ;
}
A
第二题暴力模拟一下,每次加(减)50,先减再加
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f; int main()
{
ios::sync_with_stdio(false);
cin.tie();
int p,x,y,ans=;
cin>>p>>x>>y;
for(int i=x;i>=y;i-=)
{
int j=(i/)%;
for(int k=;k<=;k++)
{
j=(j*+)%;
if(j+==p)
{
ans=i;
break;
}
}
if(ans)break;
}
if(ans)
{
cout<<<<endl;
return ;
}
for(int i=x;;i+=)
{
int j=(i/)%;
for(int k=;k<=;k++)
{
j=(j*+)%;
if(j+==p)
{
ans=i;
break;
}
}
if(ans)break;
}
int res=(ans-x+)/;
cout<<res<<endl;
return ;
}
B
第三题wa了6发,终于O(1)过了,数据1e9早该想到算法有问题
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f; int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll x,y,p,q;
int t;
cin>>t;
while(t--){
cin>>x>>y>>p>>q;
if(p==q)
{
if(x==y)cout<<<<endl;
else cout<<-<<endl;
continue;
}
if(p==)
{
if(x==)cout<<<<endl;
else cout<<-<<endl;
continue;
}
ll k1=(y-x)/(q-p);
if((y-x)%(q-p)!=)k1++;
ll k2=x/p;
if(x%p!=)k2++;
ll k3=y/q;
if(y%q!=)k3++;
ll k=max(k1,max(k2,k3));
cout<<k*q-y<<endl;
}
return ;
}
C
Codeforces Round #412的更多相关文章
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- Codeforces Round#412 Div.2
A. Is it rated? 题面 Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codefo ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring
地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...
- Codeforces Round #412 A Is it rated ?
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes Is it rated? Her ...
- Codeforces Round #412 Div. 2 第一场翻水水
大半夜呆在机房做题,我只感觉智商严重下降,今天我脑子可能不太正常 A. Is it rated? time limit per test 2 seconds memory limit per test ...
- Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #412 B. T-Shirt Hunt
B. T-Shirt Hunt time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #412 C. Success Rate
C. Success Rate time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A Is it rated?
地址:http://codeforces.com/contest/807/problem/C 题目: C. Success Rate time limit per test 2 seconds mem ...
随机推荐
- Redis持久化及复制
一.持久化的两种方式 1.RDB: RDB是在指定时间间隔内生成数据集的时间点快照(point-in-time snapshot)持久化,它是记录一段时间内的操作,一段时间内操作超过多少次就持久化.默 ...
- 2016-2017 National Taiwan University World Final Team Selection Contest J - Zero Game
题目: You are given one string S consisting of only '0' and '1'. You are bored, so you start to play w ...
- POJ - 2699 The Maximum Number of Strong Kings (最大流+枚举)
题意:有n(n<=10)个选手,两两之间打比赛,共有n*(n-1)/2场比赛,赢一场得1分.给出每个人最后的得分.求有多少个定义如下的strong king:赢了所有得分比自己高的人或本身就是分 ...
- How can For each...
Answer: I understand the IEnumerator/IEnumerable methods and properties and also how they are inte ...
- CF1137F Matches Are Not a Child's Play(LCT思维题)
题目 CF1137F 很有意思的题目 做法 直接考虑带修改的做法,上一次最大值为u,这次修改v,则最大值为v了 我们发现:\(u-v\)这条链会留到最后,序列里的其他元素相对位置不变,这条链会\(u\ ...
- Nginx 部署HTTPS
Nginx 部署HTTPS 系统:Linux Centos 7.4 x64 软件:Nginx 1.12.2 注:需要阿里云申请本地域名与证书并添加下载到本地. 注:证书文件为 xxxx.pem 与 x ...
- Cisco 交换Vlan配置
添加Vlan命令 #添加vlan100 config)#vlan 100 #重命名vlan100 config-vlan)#name vlan100 #返回上一层 config-vlan)#exit ...
- HashMap,HashTable,ConcorrentHashMap的线程方式
1.HashMap不是线程安全的,put,resize 2.HashTable是线程安全的,synchronized,但是效率较低 3.ConcorrentHashMap 对HashMap的一种加线程 ...
- 20145321 《Java程序设计》第10周学习总结
20145321 <Java程序设计>第10周学习总结 教材学习内容总结 网络编程:网络编程的实质就是两个(或多个)设备(例如计算机)之间的数据传输. IP地址:为了能够方便的识别网络上 ...
- spring MVC Action里面怎么设置UTF-8编码集
/* 编码转换,确保写数据库的时候不会出现乱码 */ public class CodingConvert{ public CodingConvert(){ // } public String to ...