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. 解决Run As -> Java Application不能运行问题

    转自:https://breakshell.iteye.com/blog/467130 点 Run As -> Java Application 不能运行,报的错误如下: Plug-in org ...

  2. 对象 Object

    在js 中创建最简单的对象,然后给它添加属性或者方法 示例如下: var obj = new Object(); //或者 var obj = {}; obj.name = '张三'; obj.fun ...

  3. react-native获取设备信息app版本信息,react-native-device-info

    安装 yarn add react-native-device-info react-native link react-native-device-info link 之后就可以直接使用了,ios ...

  4. js删除dom节点时候索引出错问题

    我们知道删除一个dom节点的时候索引就会发生了改变,甚至是错误,就算jq的ecah也无能为力,所以我们只能自己写个功能了 直接上代码把,不多说 <!DOCTYPE html> <ht ...

  5. 池以及barrier简单

    用了下CyclicBarrier,注意线程池中的线程数量设置,还有就是DB连接的时候,需要考虑单个DB能承受的最大连接数目和每个连接上能同时打开的cursor等限制,需要时可以通过jstack查看堆栈 ...

  6. es查询时报 Data too large

    报错如下: 原因: https://www.cnblogs.com/jiu0821/p/6526930.html 参数 indices.fielddata.cache.size 控制有多少堆内存是分配 ...

  7. Cookie-base 认证实现(学习笔记)

    第一步 新建一个ASP.NET core 默认项目 新建 AdminController public class AdminController : Controller { [Authorize] ...

  8. 使用karma做多浏览器的UI测试

    avalon1.6开发得差不多,这次使用先进的开发理念进行开发,比如模块化,单元测试什么... ui测试是重要的一环,之前用阿里的totoro,但打开浏览器不方便.于是从webdrieverio, n ...

  9. Android 深入浅出 - 进程生命周期(Process Lifecycle)

    Android 5 个进程等级 1. Foreground Process : 2 .Visible Process : 3. Service Process : 4. Background Proc ...

  10. 11.mysql-权限.md

    目录 -- ***********五.mysql权限问题**************** -- mysql数据库权限问题:root :拥有所有权限(可以干任何事情) -- 权限账户,只拥有部分权限(C ...