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 ...
随机推荐
- 国内NLP的那些人那些会
统计学和语言学专家都列在一起了,没有区分.1,黄昌宁,1937年生于广东,1955年考入清华大学电机系,1961年毕业并留校任教至博士生导师, 1983-1984年赴美国耶鲁大学进修,1986-198 ...
- JQuery可以轻松实现数字框
如果使用JQuery,则可以轻松实现数字框. <input type="text" name="name" value="0" run ...
- Multiple encodings set for module chunk explatform "GBK" will be used by compiler
项目用idea启动的时候,突然报了个这个 Multiple encodings set for module explatform "GBK" will be used by co ...
- Linux系统——VMware克隆
克隆VMware 1. 关闭防火墙 2. 关闭selinux 3. 删除UUID和Mac地址 4.清空网卡缓存 5.关机 ===================== 关闭防火墙 #service ip ...
- 性能调优之MySQL篇三:MySQL配置定位以及优化
1.优化方式 一般的优化方法有:硬件优化,配置优化,sql优化,表结构优化.下面仅仅介绍配置优化,具体优化设置可以参考本人另外一篇博客,传送门:https://www.cnblogs.com/lang ...
- 对Docker的一点理解
Docker是什么? Docker的思想来自于集装箱,集装箱解决了什么问题?在一艘大船上,可以把货物规整的摆放起来.并且各种各样的货物被集装箱标准化了,集装箱和集装箱之间不会相互影响.那么就不需要专门 ...
- 【Head First Servlets and JSP】笔记 27: web 应用安全
典型的安全问题:假冒者.窃听者.非法升级者 认证方式: Base64 .摘要认证 .客户端证书.表单认证,重点熟悉摘要算法( HASH . MD5 等) 安全机制:授权.认证.数据完整性.机密性 80 ...
- maven-surefire-plugin
本文参考自:https://www.cnblogs.com/qyf404/p/5013694.html surefire是maven里执行测试用例(包括testNG,Junit,pojo)的插件,他能 ...
- 照着官网来安装openstack pike之keystone安装
openstack基础环境安装完成后,现在开启安装keystone服务(在控制节点上执行下面所有操作) 1.为keystone创建数据库 mysql -u root -p MariaDB [(none ...
- saltstack之haproxy的安装配置
使用saltstack编译安装haproxy: 由于编译安装haproxy,所以安装之前需要建立编译环境,将编译环境需要安装的包单独放置在一个目录中,当编译haproxy或其他时,直接include这 ...