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)的更多相关文章

  1. Codeforces Round #497 (Div. 2) C. Reorder the Array

    Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespa ...

  2. Codeforces Round #497 (Div. 2)B. Turn the Rectangles

    Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespa ...

  3. Codeforces Round #497 (Div. 2) A. Romaji

    Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespa ...

  4. 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 ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. 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 ...

随机推荐

  1. Linux第一节课学习笔记

    我的目标是考过RHCE 开源软件有使用.复制.传播.收费.修改及创建衍生品自由,其中后二者只有开源软件才有,前四者开闭源共有.

  2. 【自动化测试:笔记一】adb命令

    1.查看当前连接的设备数 adb devices 2.连接设备 adb connect <设备名> 3.安装卸载app adb install packagesname adb unins ...

  3. Unity在WPF中的应用

    1. 本文的实现类继承于IRepository using System; using System.Linq; using System.Linq.Expressions; using Zhang. ...

  4. 记录安装 java 环境,部署环境变量遇到的小坑

    情况:先安装 jdk 7,再安装 jdk8,发现 java 的环境自动变成了 jdk8 解决: 1.在 系统的环境变量下,多出了一行: C:\Program Files (x86)\Common Fi ...

  5. 1.2.1 Excel如何从身份证号中提取日期

    在对应的单元格中我们输入公式: =MID(B3,7,4)&"年"&MID(B3,11,2)&"月"&MID(B3,13,2)&a ...

  6. 5G投资逻辑

    5G投资逻辑 关注光模块生产厂商. 通信射频滤波器,功率放大器生产厂商. 光无源器件的需求增多

  7. Git从远程clone项目报错cannot open git-upload-pack,将http.sslVerify设为false即可

    通过HTTPS访问Git远程仓库,如果服务器的SSL证书未经过第三方机构签署,那么Git就会报错 通过https访问Git远程仓库,如果服务器的SSL证书没有经过第三方机构签署,就会出现cannot ...

  8. for each in for in 与for of

    for each in for each in是作为E4X标准的一部分在javascript 1.6中发布的,而它不是ECMAScript标准的一部分.  这将意味着存在各种浏览器的兼容性问题.for ...

  9. mysql 使用 GROUP BY 时报错 ERROR 1055 (42000)

    解决方法1:SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));这种修改只是暂时性的,还是在 my.ini 文件中的sq ...

  10. JS stringObject.Match()

    JavaScript match() 方法 JavaScript String 对象 定义和用法 match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配. 该方法类似 inde ...