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 ...
随机推荐
- (33)关于django中路由自带的admin + 建表关系的讲解
admin是django自带的后台管理,在初始的时候就默认配置好了 当输入ip地址的时候后面跟admin,就会登陆管理员的后台,这个是django自带的,可以快速管理数据表(增删改查) PS:ip地址 ...
- struct 和typedef struct
1.typedef (1)typedef的使用 定义一种类型的别名,而不只是简单的宏替换(见陷阱一).用作同时声明指针型的多个对象 typedef char* PCHAR; // 一般用大写,为cha ...
- Python基础:一、编程语言分类
编程语言主要从以下几个角度进行分类: 编译型和解释型 静态语言和动态语言 强类型语言和弱类型语言 编译型语言和解释型语言 编译和解释的区别是什么? 编译器是把源程序的每一条语句都编译成机器语言,并保存 ...
- CSS3 实现圆形、椭圆形、三角形等各种形状样式
CSS3 圆形 #css3-circle{ width: 150px; height: 150px; border-radius: 50%; background-color: #232323;} C ...
- Javascript 将一个句子中的单词首字母转成大写
Javascript 将一个句子中的单词首字母转成大写 先上代码 function titleCase(str) { str = str.toLowerCase().split(" &quo ...
- 基于redis的 分布式锁 Java实现
package com.hs.services.lock; import java.util.concurrent.TimeUnit; import javax.annotation.Resource ...
- freemarker语法介绍及其入门教程实例
# freemarker语法介绍及其入门教程实例 # ## FreeMarker标签使用 #####一.FreeMarker模板文件主要有4个部分组成</br>#### 1.文本,直接输 ...
- Excel 二维数组(数据块)旋转/翻转技巧
Excel 二维数组(数据块)旋转/翻转技巧 原创 2017-12-30 久石六 久石六 工作中遇到个问题,需要将Excel中的数据块或者说二维数组向右旋转90度,才能再加工处理.当然,不是旋转文本方 ...
- greendao3.2.0使用
源代码地址 https://github.com/greenrobot/greenDAO buildscript { repositories { jcenter() mavenCentral() } ...
- 20165312 2017-2018-2 《JAVA程序设计》第2周学习总结
20165312 2017-2018-2 <JAVA程序设计>第2周学习总结 一.对上一周学习的查漏补缺 1.上周在虚拟机中进行编译程序时出现错误,在上一周的博客中我有提到,当时还未找到解 ...