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 ...
随机推荐
- python 阿狸的进阶之路(8)
异常处理 http://www.cnblogs.com/linhaifeng/articles/6232220.html(转) 网络编程socket http://www.cnblogs.com/li ...
- as3调用外部应用程序 as调用外部exe文件as3调用bat文件 未测试
private function callTest(event: Event): void{callExe("d:/a.exe");callBat("d:/a.bat&q ...
- too many connections 解决方法
最近写javaee项目的时候,mysql报了too many connections的错误,百度的内容有一些有问题,所以我重新写一下我的解决方法. mysql -u root -p 回车输入密码进入m ...
- tfs对接数据-File
在使用tfs时,数据结构 /** * getFile */ @RequestMapping("/tfs/{fileName}") public ResponseEntity< ...
- 关于cordova 状态栏设置
https://blog.csdn.net/u011127019/article/details/58104056
- UNITY2018.3 在editor下运行时new memoryprofiler显示 shader占用内存很大的问题在安卓上并没有看到
在安卓机上完全看不到shader占用的内存,但问题是,shader在安卓上真的几乎不占用内存了?(我们的游戏中只使用了mobile下的shader) 参考下面这个文章,说是真机上也有: Unity3D ...
- eclipse打断点,进行弹窗提示后点击是才进入debug视图,这个要怎么恢复
window --> preferences --> Run/Debug --> Perspectives 里的 open the associated perspective wh ...
- CentOS 6.x 默认源中带了mysql-server,可以使用yum安装。
1.执行安装命令:yum install mysql-server 2.初始化数据库,使用命令1# service mysqld start 启动MSQL service mysqld stop ...
- delphi调用LUA函数来处理一些逻辑
替同事做了个洛奇英雄传自动染色程序,关于屏幕取色的. 因为里面他对颜色的要求比较复杂,改动也比较大,于是我让他把逻辑写在 lua 脚本里面. uses LUA, LUALIB; function lu ...
- Swift中的的注释
1. Swift支持与OC中相同的 /**/ ./***/ 不同点Swift支持 /*/**/ 这样的注释 ,多行注释 2. 直接双杠注释 // 单行注释 3. 利用 //MARK: 返 ...