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. NRF51822之RNG

    在裸机下官方已经提供另一个RNG的例子(RF51_SDK_10.0.0_dc26b5e\examples\peripheral\rng) 好了现在我将给出在蓝牙模式下如何使用例子 #include & ...

  2. js 监听组合键盘事件

    有些时候,我们需要在网页上,增加一些快捷按键,方便用户使用一些常用的操作,比如:保存,撤销,复制.粘贴等等. 我们所熟悉的按键有这么集中类型: 单独的按键操作,如:delete.up.down等 两位 ...

  3. C语言中的__LINE__宏

    在C语言中,有这么四个预定义的宏: 当前文件: __FILE__ 当前行号: __LINE__ 当前日期: __DATE__ 当前时间: __TIME__ 这4个宏在代码编译的时候,由编译器替换成实际 ...

  4. URL中文乱码及特殊字符处理

    一.中文乱码 IE高版本(应该是9以上,不确定),在get方式请求中中文传到后台容易出现乱码问题.解决方法如下: 1.第一种,换成post方式 如果可以得话换成post方式就可以.如果采用表单或者aj ...

  5. 保存对象报错with two open Sessions

    purorderService.save(newpur);出现如下 org.springframework.orm.hibernate3.HibernateSystemException: illeg ...

  6. jquery_ajax 地址三级联动

    jquery 的三级地址联动,原理与javascript类似,只是在触发请求的时候,使用封装好的 $.get ,$post,$.ajax 方法去执行,其余的都是一样的,后台服务器请求文件是一样的,前台 ...

  7. Logstash收集nginx日志之使用grok过滤插件解析日志

    grok作为一个logstash的过滤插件,支持根据模式解析文本日志行,拆成字段. nginx日志的配置: log_format main '$remote_addr - $remote_user [ ...

  8. 解决error: only position independent executables (PIE) are supported

    在Android.mk文件中添加以下内容 LOCAL_CFLAGS += -pie -fPIE LOCAL_LDFLAGS += -pie -fPIE 原帖地址:http://blog.csdn.ne ...

  9. 循环取到json中的字段数据,加到html中

    $.ajax({ type:'post', data:{specialName:specialName,count:count}, url:"admin/pcAdminGetArticleL ...

  10. Delphi 不使用自带模板创建服务

    program Project1; uses Windows, WinSvc; const ServiceName: pchar = 'SnowWings Service'; DisplayName: ...