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. vue eslint 代码自动格式化

    vue-cli 代码风格为 JavaScript Standard Style 代码检查规范严格,一不小心就无法运行,使用eslint的autoFixOnSave可以在保存代码的时候自动格式化代码 V ...

  2. django 认证模块auth,表单组件form

    django认证系统(auth): 1.首先我们在新窗口中打开一个django项目,之后点击,

  3. 页面中的checkbox多选值获取

    依据name名称获取选中值 var arr=document.getElementsByName("name");arr是一个数组,就是所有checkbox的值:for(i=0;i ...

  4. JVM 学习集合

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

  5. python import package at different path

    1.导入上一级目录的package import sys sys.path.append('..') import <package> # import package at ../ 2. ...

  6. haproxy + nginx + proxy protocol 获得客户真实IP方法

    公司网站架构为: 前面2台HA负载均衡,后面3台Nginx负载均衡反向代理,然后后面有N台WEB服务器 由于要统计IP,需要在WEB服务器日志里体现客户端真实IP 那么问题来了,通过HA代理的HTTP ...

  7. LeetCode OJ 15. 3Sum

    题目 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all ...

  8. mac shortcut

    在Windows系统中,如果你想跳到行首.行尾直接点击home.end键就可以了,但MacBook的相关快捷键就有些区别了,相关快捷键如下: Ctrl+A:到行首(达到Home键的效果) .fn键+左 ...

  9. 漫谈C指针:参数传递的三道题目

    漫谈C指针:参数传递的三道题目 2009-07-02 开讲之前,我先请你做三道题目.(嘿嘿,得先把你的头脑搞昏才行……唉呀,谁扔我鸡蛋?) 考题一,程序代码如下: [c] view plaincopy ...

  10. hadoop-1(单机模式配置)

    下一次的目标是: 把Hadoop的伪分布式配置出来 1:ssh免密码登陆第一步 2:安装java环境 3:安装hadoop2