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 ...
随机推荐
- MyCat配置详解
MyCAT 配置解析 server.xml Mycat的配置文件,设置账号.参数等schema.xml Mycat对应的物理数据库和数据库表的配置rule.xml Mycat分片(分库分表)规则 一 ...
- python:Hamlet英文词频统计
#CalHamletV1.py def getText(): #定义函数读取文件 txt = open("hamlet.txt","r").read() txt ...
- 网络ping不通原因总结
1.检查主机是否在线,硬件是否连接好 2.查看ip地址是否输入正确 3.查看是否防火墙拦截,如果有拦截关闭防火墙 4.两台电脑是否接入同一局域网(WiFi也是)
- PythonStudy——Pycharm 小技巧
分享Pycharm中一些不为人知的技巧 工欲善其事必先利其器,Pycharm 是最受欢迎的Python开发工具,它提供的功能非常强大,是构建大型项目的理想工具之一,如果能挖掘出里面实用技巧,能带来事半 ...
- 数组中只出现一次的数字(java实现)
问题描述 一个整型数组里除了两个数字之外,其他的数字都出现了偶数次.请写程序找出这两个只出现一次的数字. 解题思路 如果数组中只有一个数字出现奇数次,则将数组中所有的数字做异或可得该数字. 数组中有两 ...
- 第一个Unity3D脚本
学习就该简单粗暴,看了一天Unity3d的教程加文档,尝试一个小练习,再快速写个博客加深印象. 一:首先建立一个空白工程,创建一个空GameObject,在Assets Pannel中创建一个名为Le ...
- [UE4]字体材质
一.准备好一个字体文件,直接拖放到内容浏览器 二.创建一个名为testFontMaterial的UserWidget,添加一个TextBlock到默认的CanvasPanel.Font Family: ...
- css 实现多行文本末尾显示省略号
思路: 省略号使用绝对定位添加,开头部分避免突兀使用c3渐变背景颜色 <!DOCTYPE html> <html lang="en"> <head&g ...
- sed -i命令详解
[root@www ~]# sed [-nefr] [动作] 选项与参数: -n :使用安静(silent)模式.在一般 sed 的用法中,所有来自 STDIN 的数据一般都会被列出到终端上.但如果加 ...
- solr schema.xml Field属性详解
<field name="id" type="string" indexed="true" stored="true&quo ...