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 ...
随机推荐
- C++中几种测试程序运行时间的方法<转>
转的地址:https://www.cnblogs.com/silentteen/p/7532855.html 1.GetTickCount()函数 原理: GetTickCount()是获取系统启动后 ...
- Java工具类DateFormatUtils详解
日期和时间格式化实用程序和常量public static String format(Calendar calendar, String pattern) 说明:将日历格式化为特定的模式:参数:cal ...
- 翻转单链表 leetcode Reverse Linked List
翻转一个单链表.这个题目听说很多次了,总感觉肯定不是什么难题. 现在真的有点好高骛远了!总感觉那种很难的算法题才是难题,这种题没必要做.其实眼高手低啊. 这种easy题,我都不能一遍ac,这遇到白板编 ...
- newCachedThreadPool使用案例
newCachedThreadPool 缓存默认60s 猜下你的结果 package com.juc.threadpool; import java.util.concurrent.ExecutorS ...
- Hbase数据读写流程
From: https://blog.csdn.net/wuxintdrh/article/details/69056188 写操作: Client写入,存入Memstore,Memstore满则Fl ...
- CAS无锁技术
前言:关于同步,很多人都知道synchronized,Reentrantlock等加锁技术,这种方式也很好理解,是在线程访问的临界区资源上建立一个阻塞机制,需要线程等待 其它线程释放了锁,它才能运行. ...
- 【转】JS windows.open()详解
window.open(url, name, features, replace) Arguments - 参数 url 可选字符串参数,指向要在新窗口中显示的文档的URL.如果省略该参数,或者参 ...
- CentOS 7下源码安装zabbix服务
安装环境需要LAMP或者LNMP先搭建好 在此我使用上一篇搭建好的LNMP环境来安装zabbix 1.下载zabbix http://www.zabbix.com/download.php 2.安装及 ...
- C++ AfxBeginThread和AfxEndThread 使用方法
启动线程: CWinThread* AfxBeginThread( 线程函数,this ); 线程的退出: 在刚刚使用的时候,退出线程的方法有问题,导致退出的时候异常. 下面说线程退出的方法: 1. ...
- ztree根据treeId展开指定节点并触发单击事件
ztree.expandNode(ztree.getNodeByParam("id",treeId,null));//展开指定节点 ztree.selectNode(ztree.g ...