Codeforces Round #497 (Div. 2)
Codeforces Round #497 (Div. 2)
https://codeforces.com/contest/1008
A
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<node>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#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<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
const double oula=0.57721566490153286060651209;
using namespace std; bool Check(char ch){
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') return true;
return false;
} int main(){
std::ios::sync_with_stdio(false);
string str;
cin>>str;
if(str.length()==){
if(!Check(str[])&&str[]!='n') cout<<"NO";
else cout<<"YES";
return ;
}
for(int i=;i<str.length()-;i++){
if(!Check(str[i])&&str[i]!='n'){
if(!Check(str[i+])){
cout<<"NO";
return ;
}
}
}
if(!Check(str[str.length()-])&&str[str.length()-]!='n'){
cout<<"NO";
return ;
} cout<<"YES";
}
B
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<node>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#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<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
const double oula=0.57721566490153286060651209;
using namespace std; vector<pii>ve; int main(){
std::ios::sync_with_stdio(false);
int n;
int x,y;
cin>>n;
for(int i=;i<n;i++){
cin>>x>>y;
if(x<y) swap(x,y);
ve.pb({x,y});
}
x=ve[].first;
for(int i=;i<ve.size();i++){
if(x>=ve[i].first){
x=ve[i].first;
}
else if(x>=ve[i].second){
x=ve[i].second;
}
else{
cout<<"NO";
return ;
}
}
cout<<"YES";
}
C
题意:给一个序列,你需要生成这个序列的任意一个排列,使得这个排列上某个位置的值大于原序列的值,求最多能有多少个数符合条件
思路:排个序比较即可
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<node>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#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<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
const double oula=0.57721566490153286060651209;
using namespace std; int a[maxn]; bool cmp(int a,int b){return a>b;} int main(){
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i];
}
sort(a+,a+n+,cmp);
int pos=;
for(int i=;i<=n;i++){
if(a[pos]>a[i]){
pos++;
}
}
cout<<pos-<<endl;
}
D
组合数学
题意:给你一个长方体,长,宽,高分别为A,B,C,求有多少种方案使a×b×c能够拼凑出这个长方体 a|A,b|B,c|C
思路:先预处理出每个数的因子个数,然后考虑A,B,C每个数有7种情况
001 是A的因数
010 是B的因数
011 是A的因数也是B的因数,即是gcd(A,B)的因数
100 是C的因数
101 是A的因数也是C的因数,即是gcd(A,C)的因数
110 是B的因数也是C的因数,即是gcd(B,C)的因数
111 是A的因数也是B的因数也是C的因数,即是gcd(A,B,C)的因数
最后枚举每一种状态相乘即可
参考博客:https://blog.csdn.net/codeswarrior/article/details/81146331
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<node>::iterator
#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<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
const double oula=0.57721566490153286060651209;
using namespace std; ll cal(int n,int m){
ll ans=;
for(int i=;i<=m;i++){
ans=ans*(n-i+)/i;
}
return ans;
} bool Check(int a,int b,int c){
if((a&)&&(b&)&&(c&)) return true;
if((a&)&&(c&)&&(b&)) return true;
if((b&)&&(a&)&&(c&)) return true;
if((b&)&&(c&)&&(a&)) return true;
if((c&)&&(a&)&&(b&)) return true;
if((c&)&&(b&)&&(a&)) return true;
return false;
} int cnt[],used[];
int fac[maxn]; void Init(){
for(int i=;i<maxn;i++){
for(int j=i;j<maxn;j+=i){
fac[j]++;
}
}
} int main(){
std::ios::sync_with_stdio(false);
int t;
Init();
cin>>t;
ll x,y,z;
while(t--){
cin>>x>>y>>z;
ll xy=__gcd(x,y);
ll yz=__gcd(y,z);
ll xz=__gcd(x,z);
ll xyz=__gcd(xy,z);
cnt[]=fac[xyz];
cnt[]=fac[yz]-fac[xyz];
cnt[]=fac[xz]-fac[xyz];
cnt[]=fac[z]-fac[xz]-fac[yz]+fac[xyz];
cnt[]=fac[xy]-fac[xyz];
cnt[]=fac[y]-fac[xy]-fac[yz]+fac[xyz];
cnt[]=fac[x]-fac[xy]-fac[xz]+fac[xyz];
ll ans=;
for(int i = ; i < ; i++){
for(int j = i; j < ; j++){
for(int k = j; k < ; k++){
if(Check(i,j,k)){
memset(used,,sizeof(used));
used[i]++;
used[j]++;
used[k]++;
ll tmp = ;
for(int q = ; q < ; q++){
if(used[i])
tmp *= cal(cnt[q]+used[q]-,used[q]);
}
if(tmp > )
ans += tmp;
}
}
}
}
cout<<ans<<endl;
}
}
E
交互题
题意:给定n,在1-n中求a,b两个数,假设你猜的数是x,y
当a==0&&y==0时,返回0
当x比a小,返回1
当y比b小,返回2
当x比a大或y比b大,返回3
思路:不断二分逼近即可
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<node>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#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<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
const double oula=0.57721566490153286060651209;
using namespace std; int main(){
std::ios::sync_with_stdio(false);
ll x,n;
cin>>n;
ll ans1=,ans2=,a=,b=;
for(int i=;i<;i++){
cout<<ans1+a<<" "<<ans2+b<<endl;
cin>>x;
if(x==) return ;
else if(x==){
ans1+=a;
a=min(n-ans1,a<<);
}
else if(x==){
ans2+=b;
b=min(n-ans2,b<<);
}
else{
a=max(a>>,1LL);
b=max(b>>,1LL);
}
}
}
Codeforces Round #497 (Div. 2)的更多相关文章
- Codeforces Round #497 (Div. 2) C. Reorder the Array
Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespa ...
- Codeforces Round #497 (Div. 2)B. Turn the Rectangles
Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespa ...
- Codeforces Round #497 (Div. 2) A. Romaji
Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespa ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
随机推荐
- spring jpa + mybatis快速开始:
springmvc开始搭建 源码地址 https://gitee.com/flydb/spingjpamy pom: <packaging>war</packaging> &l ...
- postgresql安装与启动(mac os)
转自https://blog.csdn.net/kmust20093211/article/details/44359053 --------数据库的安装与创建----------- 安装 brew ...
- 【Jmeter】api性能测试总结
1.前提概念 平时常用的性能测试:api性能测试+场景性能测试:今天就说一说api性能测试 2.如何进行性能测试? 需求:对某api进行性能测试,看看最大承受的并发数,分析下图表 分析: 错误思路:当 ...
- babelrc 中的 presets 字段(env, react)和 plugins 字段(dynamic-import-webpack, transform-object-rest-spread, ...)
一.presets 字段 目前用到 presets: [ 'env', 'react' // react 转码规则 ]: 只有 env 时,作用和 latest 相同,包括 es5.es6.es7 ...
- threading模块小结
这篇文章是别人文章的一个观后小结,不是什么原创. 首先第一个例子: import threading import time def worker(): print "worker& ...
- mysqlbinlog基于时间点恢复
基于时间点恢复 /data/mysq/mysqlbin.000026 #mysqlbinlog文件,恢复如下内容: 注意:按照时间点恢复时,可能同一个时间点有其他的操作,要结合上下文的时间选取~ # ...
- 报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1
错误现象: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-com ...
- Python日志模块logging&JSON
日志模块的用法 json部分 先开一段测试代码:注意 str可以直接处理字典 eval可以直接将字符串转成字典的形式 dic={'key1':'value1','key2':'value2'} ...
- U3D学习12-黑暗之光实例
1.static勾选后,在scene场景操作后,导致不断烘焙,cpu占用高? 取消自动烘焙 2.UI操作事件 //监听事件增加 mainInputField.onValueChange ...
- Node Express服务器设置与优化
一.代码部分 * 启用gzip压缩,减少网络数据量 var compression = require('compression')var express = require('express')va ...