Codeforces Beta Round #42 (Div. 2)

http://codeforces.com/contest/43

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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; string str;
map<string,int>mp; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=;i<=n;i++){
cin>>str;
mp[str]++;
}
string ans;
int Max=;
for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++){
if(Max < it->second){
Max = it->second;
ans = it->first;
}
}
cout<<ans<<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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; string s1,s2;
map<char,int>mp; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
getline(cin,s1);
getline(cin,s2);
for(int i=;i<s1.length();i++){
mp[s1[i]]++;
}
int flag=;
for(int i=;i<s2.length();i++){
if(s2[i]==' ') continue;
if(mp[s2[i]]){
mp[s2[i]]--;
}
else{
flag=;
}
}
if(!flag) cout<<"YES"<<endl;
else cout<<"NO"<<endl; }

C

cf的评测机是真的快。。。写了个n^2的假算法都过了。。。正解应该是:sum(num%3==0)/2+min(sum(num%3==1),sum(num%3==2))

 #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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; ll a[]; int book[]; bool Check(ll a,ll b){
ll tmpa=a;
ll tmpb=b;
while(tmpa){
tmpb=tmpb*+tmpa%;
tmpa/=;
}
if(tmpb%==) return true;
tmpa=a;
tmpb=b;
while(tmpb){
tmpa=tmpa*+tmpb%;
tmpb/=;
}
if(tmpa%==) return true;
return false;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=;i<=n;i++) cin>>a[i];
int ans=;
for(int i=;i<=n;i++){
if(!book[i]){
for(int j=i+;j<=n;j++){
if(!book[j])
if(Check(a[i],a[j])){
ans++;
book[j]=;
break;
}
}
}
}
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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n,m,i,j;
scanf("%d%d",&n,&m);
if((n%==&&m%==)||(n==&&m>)||(m==&&n>)){
printf("1\n%d %d 1 1\n",n,m);
for(i=;i<=n;i++){
if(i%==)
for(j=;j<=m;j++)printf("%d %d\n",i,j);
else
for(j=m;j>;j--)printf("%d %d\n",i,j);
}
printf("1 1\n");
}
else if(n%==){
printf("0\n1 1\n");
for(i=;i<=n;i++){
if(i%==)
for(j=;j<=m;j++)printf("%d %d\n",i,j);
else
for(j=m;j>;j--)printf("%d %d\n",i,j);
}
for(i=n;i>;i--)printf("%d 1\n",i);
}
else{
printf("0\n1 1\n");
for(i=;i<=m;i++){
if(i%==)
for(j=;j<=n;j++)printf("%d %d\n",j,i);
else
for(j=n;j>;j--)printf("%d %d\n",j,i);
}
for(i=m;i>;i--)printf("1 %d\n",i);
} }

E

模拟

 #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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; int n,s,t[][],k[],v[][],ans; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
scanf("%d%d",&n,&s);
for (int i=;i<=n;i++){
scanf("%d",&k[i]);
for (int j=;j<=k[i];j++){
scanf("%d%d",&v[i][j],&t[i][j]);
t[i][j]+=t[i][j-];
t[i][k[i]+]=<<;
}
}
for (int i=;i<n;i++)
for (int j=i+;j<=n;j++){
int t1=,t2=,x1=,x2=,tmp=,tmp2=-;
while (t1<=k[i] || t2<=k[j]){
int tmp1=min(t[i][t1],t[j][t2]);
x1+=(tmp1-tmp)*v[i][t1];
x2+=(tmp1-tmp)*v[j][t2];
if (t[i][t1]<t[j][t2]) t1++;else t2++;
if (x1>x2 && tmp2==) ans++;
if (x1<x2 && tmp2==) ans++;
if (x1>x2) tmp2=;
if (x1<x2) tmp2=;
tmp=tmp1;
}
}
printf("%d\n",ans);
}

Codeforces Beta Round #42 (Div. 2)的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

随机推荐

  1. 【平台兼容性】jeecg3.7 兼容weblogic 部署改造方案

    MyEclipse 配置 WebLogic 10.3.3请参考: https://my.oschina.net/aini3884/blog/895689 常见问题: 1. problem: cvc-e ...

  2. mp3-

  3. JVM 学习集合

    内存回收要做的事: 确定哪些内存需要回收,确定什么时候需要执行GC,如何执行GC 以最简单的本地变量引用:Object obj = new Object()为例: Object obj表示一个本地引用 ...

  4. es6初级之解构----之二 及 键值反转实现

    1.解构: 不定参数,扩展表达式 let arr = [100, 201, 303, 911]; let [one, ...others] = arr; console.log(others.leng ...

  5. hadoop搭建部署

    HDFS(Hadoop Distributed File System)和Mapreduce是hadoop的两大核心: HDFS(文件系统)实现分布式存储的底层支持 Mapreduce(编程模型)实现 ...

  6. C语言中插入汇编nop指令

    工作过程中,有的时候需要打桩cycle,想在C语言中插入nop指令,可以采取的方法是 头文件中加入#inlude <stdio.h> 定义一个内联函数,然后调用这个函数,不过得测一下平台调 ...

  7. 软件工程github使用小结

    1.在 https://github.com/join 这个网址处申请注册一个Github账号,申请成功后可在https://github.com/login 处利用刚刚注册的账号进行登录,才能开始在 ...

  8. mac使用brew安装sshpass

    brew安装sshpass brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Form ...

  9. adb INSTALL_FAILED_UPDATE_INCOMPATIBLE

    今天用Eclipse运行项目时出错: LOG: [2018-05-09 14:16:19 - Module_Android_Demo] ------------------------------ [ ...

  10. git 恢复到旧版本命令

    1.第一步:找到你想恢复到的版本号:可以在git提交日志中查看-> 找到版本号,复制下来,在git项目根目录下打开git命令窗口: 输入:git reset --hard xxxxxxxxxxx ...