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 ...
随机推荐
- 用JS 和 jQery获取屏幕的高度和宽度
用的时候,网上找了下,放在一起,方便以后查阅 document.body.clientWidth document.body.offsetWidth(包括线宽)//网页可见区域宽 document.b ...
- Mp4 to Img
# -*- coding: utf-8 -*- """ Created on Thu May 3 16:51:50 2018 """ # 录 ...
- jquery实现分页+单删批删
//定义一个分页的方法 public function fenye(){ //查询满足条件的总条数 $count = M("regis")->count(); //设置每页显 ...
- 关于PHP Notice: A non well formed numeric value encountered, 你知道多少
---------------------------------------------------------------------------------------------- A non ...
- vscode 右击文件||文件夹添加快捷方式
操作注册表步骤 1.按下win+R 2.输入redegit,打开注册表 3.找到HKEY_CLASSES_ROOT/*/shell路径 4.新建/项:命名Open with visual code 5 ...
- JS代码注释
1.css和js都可以使用/**/进行注释 2.html使用<!---->注释 3.单行js代码可以使用//进行注释 <!DOCTYPE html> <html lang ...
- Android签名
参考文档:http://blog.csdn.net/u010316858/article/details/53159678 http://www.cnblogs.com/wanqieddy/p/355 ...
- C++ AfxBeginThread和AfxEndThread 使用方法
启动线程: CWinThread* AfxBeginThread( 线程函数,this ); 线程的退出: 在刚刚使用的时候,退出线程的方法有问题,导致退出的时候异常. 下面说线程退出的方法: 1. ...
- eclipse maven项目 热部署
热部署:本地项目一键发布到远程服务器中 热部署步骤: 1. 在tomat/conf/tomcat-users.xml添加 <role rolename="manager-gui&quo ...
- windows 激活venv问题
.\ven\Scripts\activate.\ven\Scripts\activate : 无法加载文件 D:\github\ven\Scripts\activate.ps1,因为在此系统上禁止运行 ...