Codeforces Round #450 (Div. 2)
Codeforces Round #450 (Div. 2)
http://codeforces.com/contest/900
A
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int a[];
int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
int u,v;
for(int i=;i<n;i++){
cin>>u>>v;
if(u>) a[]++;
else a[]++;
}
if(a[]<=||a[]<=) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
B
模拟除法
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int a[];
ll fac[];
int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
int a,b,c;
cin>>a>>b>>c;
int co=;
while(){
a*=;
int k=a/b;
a%=b;
if(k==c){
cout<<co<<endl;
return ;
}
co++;
if(co>=) break;
}
cout<<-<<endl; }
C
找规律
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int n;
int a[maxn],cnt[maxn]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
cin>>n;
int max1=,max2=;
for(int i=;i<=n;i++) cin>>a[i];
for(int i=;i<=n;i++){
if(a[i]>max1){
max2=max1;
max1=a[i];
cnt[a[i]]--;
}
else if(a[i]>max2){
cnt[max1]++;
max2=a[i];
}
}
int max3=-maxn,ans;
for(int i=;i<=n;i++){
if(cnt[i]>max3){
max3=cnt[i];
ans=i;
}
}
cout<<ans<<endl; }
D
记忆化搜索+容斥
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int x,y;
map<int,int>mp; ll pow_mul(ll a,ll b){
ll ans=;
while(b){
if(b&) ans=(ans*a)%MOD;
b>>=;
a=(a*a)%MOD;
}
return ans;
} ll dp(int x){
if(x==) return ;
if(mp.count(x)) return mp[x];
mp[x]=pow_mul(,x-);
for(int i=;i*i<=x;i++){
if(x%i==){
mp[x]=(mp[x]-dp(x/i)+MOD)%MOD;
if(i!=x/i){
mp[x]=(mp[x]-dp(i)+MOD)%MOD;
}
}
}
return mp[x]=(mp[x]-dp()+MOD)%MOD;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
cin>>x>>y;
if(y%x){
cout<<<<endl;
}
else{
cout<<dp(y/x)<<endl;
} }
E
DP
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */
pii d[maxn];
int f[][maxn], n, m, b[maxn];
char a[maxn]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
cin >> n;
for (int i = ; i <= n; i++)
cin >> a[i];
cin >> m;
for (int i = ; i <= n; i++)
{
if (a[i] == '?')
b[i] = b[i-] + ;
else b[i] = b[i-];
if (a[i] != 'a')
f[][i] = f[][i-]+;
if (a[i] != 'b')
f[][i] = f[][i-]+;
if (f[!(m&)][i] >= m)
d[i] = {d[i-m].first + , -(b[i]-b[i-m]-d[i-m].second)};
d[i] = max(d[i-], d[i]);
}
cout << - d[n].second; }
Codeforces Round #450 (Div. 2)的更多相关文章
- Codeforces Round #450 (Div. 2) D.Unusual Sequences (数学)
题目链接: http://codeforces.com/contest/900/problem/D 题意: 给你 \(x\) 和 \(y\),让你求同时满足这两个条件的序列的个数: \(a_1, a_ ...
- Codeforces Round #450 (Div. 2) C. Remove Extra One
题目链接 题意:让你去掉一个数,使得剩下的数的record最多,当1≤j<i的aj<ai1 \leq j< i的a_j<a_i1≤j<i的aj<ai时aia_i ...
- Codeforces Round #450 (Div. 2) ABCD
这次还是能看的0 0,没出现一题掉分情况. QAQ前两次掉分还被hack了0 0,两行清泪. A. Find Extra One You have n distinct points on a p ...
- Codeforces Round #450 (Div. 2) C. Remove Extra One【*模拟链表/一个数比前面所有数大就是个record。删掉一个数,让record的个数尽量多。】
C. Remove Extra One time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #450 (Div. 2) B. Position in Fraction【数论/循环节/给定分子m 分母n和一个数c,找出c在m/n的循环节第几个位置出现,没出现过输出-1】
B. Position in Fraction time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #450 (Div. 2) A. Find Extra One【模拟/判断是否能去掉一个点保证剩下的点在Y轴同侧】
A. Find Extra One time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 【Codeforces Round #450 (Div. 2) C】Remove Extra One
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举删除第i个数字. 想想删掉这个数字后会有什么影响? 首先,如果a[i]如果是a[1..i]中最大的数字 那么record会减少1 ...
- 【Codeforces Round #450 (Div. 2) B】Position in Fraction
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 找循环节就好. ->其实可以不用找出来整个循环节. 有找到c就直接输出. 找到了循环节还没找到的话,直接输出无解. [代码] ...
- 【Codeforces Round #450 (Div. 2) A】Find Extra One
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟. 看看Y左边或右边的点个数是否<=1 [代码] #include <bits/stdc++.h> using ...
随机推荐
- go遍历某个文件夹
//遍历文件夹 dir, err := ioutil.ReadDir("./upload_tmp")for _,file := range dir{ logs.Debug(file ...
- Windows 端口占用解决
- Zookpeer集群节点
Adaptive Communication Environment(自适配通信环境),简称ACE. reference artfile:zookeeper单节点与集群的安装https://blog. ...
- 反射机制(java)
反射机制 反射机制可通过在运行时加载类名而获取类,并对其进行操作.工厂模式,动态代理中较常用到. 在实际场景中:由于有好多类具有共同的接口样式,而他们又用的不是很频繁,如果在服务器中保有这些类会占用资 ...
- Hbase数据读写流程
From: https://blog.csdn.net/wuxintdrh/article/details/69056188 写操作: Client写入,存入Memstore,Memstore满则Fl ...
- unity脚本执行顺序
Awake ->OnEable-> Start ->-> FixedUpdate-> Update -> LateUpdate ->OnGUI ->R ...
- ReactiveX 学习笔记(16)RxPY
RxPY RxPY 是 ReactiveX 的 Python语言实现. # 安装 RxPY $ pip3 install rx Successfully installed rx-1.6.1 Basi ...
- html兼容手机浏览器
其实主要就是改掉HTML页面声明: 在网页中加入以下代码,就可以正常显示了: <meta name="viewport" content="width=device ...
- swift重写导航控制器类的 initialize 方法
//这个方法,是当这个类第一次被创建时调用,且只调用一次 override class func initialize() { let navBar = UINavigationBar.appeara ...
- HTML 视频
在html5中使用视频,只要添加元素<video></video>元素表示. <video>有几个属性: src 指定音频文件的路径 poster 视频播放之前显示 ...