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

    FDLocalSQL http://docwiki.embarcadero.com/Libraries/Berlin/en/FireDAC.Phys.SQLiteVDataSet.TFDLocalSQ ...

  2. 反射机制(java)

    反射机制 反射机制可通过在运行时加载类名而获取类,并对其进行操作.工厂模式,动态代理中较常用到. 在实际场景中:由于有好多类具有共同的接口样式,而他们又用的不是很频繁,如果在服务器中保有这些类会占用资 ...

  3. HBASE小结--待续使用

    构建在HDFS之上的分布式,面向列的存储系统,使用zookeeper做协同服务,在需要实时读写和随机访问超大规模数据集的时候使用 缺点:非关系型,不支持SQL,数据类型单一(字符串,无类型),之支持单 ...

  4. c++复习:C++输入和输出流

    C++输入和输出流 1.I/O流的概念和流类库的结构 程序的输入指的是从输入文件将数据传送给程序,程序的输出指的是从程序将数据传送给输出文件. C++输入输出包含以下三个方面的内容: 对系统指定的标准 ...

  5. linux 3.10 一次softlock排查

    x86架构.一个同事分析的crash,我在他基础上再次协助分析,也没有获得进展,只是记录一下分析过程.记录是指备忘,万一有人解决过,也好给我们点帮助. 有一次软锁,大多数cpu被锁,log中第一个认为 ...

  6. [C语言]变量VS常量

    -------------------------------------------------------------------------------------------- 1. 固定不变 ...

  7. 让一个非窗口组件(non-windowed component)可以接受来自Windows的消息

    为什么要这样做? 有时候我们需要一个非窗口组件(比如一个非继承自TWinContrl的组件)可以接受Windows消息.要接受消息就需要一个窗口句柄,但是非窗口组件却没有句柄.这篇文章将讲述怎么让一个 ...

  8. 动态修改属性设置 easyUI

    if(条件){  $("#area").combobox({ required:false }); }else{ $("#area").combobox({ r ...

  9. easyUi onLoadSuccess:、onChange这些事件不能嵌套使用!!!!

    easyUi  onLoadSuccess:.onChange这些事件不能嵌套使用!!!!

  10. linux最大允许的文件描述符open files数nofile修改

    open file resource limit 是linux中process可以打开的文件句柄数量.增加这个数值需要调整两个配置: 第一步, 修改系统最大允许的文件描述符 查看当前的设置: $ ca ...