Codeforces Beta Round #61 (Div. 2)
Codeforces Beta Round #61 (Div. 2)
http://codeforces.com/contest/66
A
输入用long double
#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 eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
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);
long double n;
cin>>n;
if(n>=-&&n<=) cout<<"byte"<<endl;
else if(n>=-&&n<=) cout<<"short"<<endl;
else if(n>=-&&n<=) cout<<"int"<<endl;
else if(n<) cout<<"long"<<endl;
else{
cout<<"BigInteger"<<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 eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int a[]; 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++){
int j=i-;
int co=;
while(j>=){
if(a[j+]>=a[j]){
j--;
co++;
}
else{
break;
}
}
j=i+;
while(j<=n){
if(a[j-]>=a[j]){
j++;
co++;
}
else{
break;
}
}
if(co>ans) ans=co;
}
cout<<ans<<endl;
}
C
模拟题
#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 eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; string s,t;
int res1,res2;
map<string,int> M,N; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
while(cin>>t)
{
s=t;
int F=;
while()
{
int x=s.find_last_of('\\');
if (x==) break;
s=s.substr(,x);
int f=N[s];
M[s]+=F;
N[s]++;
res1=max(res1,M[s]);
res2=max(res2,N[s]);
if (!f) F++;
}
}
cout<<res1<<' '<<res2<<endl;
}
D
找出3个数,使他们两两的公约数互不为1,他们三个的公约数为1,剩下的数就输出他们的倍数即可
#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 eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int a[]={,,}; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
if(n==){
cout<<-<<endl;
}
else{
for(int i=;i<n;i++){
if(i<){
cout<<a[i]<<endl;
}
else{
cout<<*i<<endl;
}
}
}
}
E
找出a[i]-b[i]前缀和的最小值,然后依次减去,如果发现minn大于等于0的情况,说明走的通,逆向同理
#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 eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n;
int a[];
int b[];
set<int>se;
set<int>::iterator it; void func(int x){
int minn=a[]-b[],pre=minn;
for(int i=;i<n;i++){
pre+=a[i]-b[i];
minn=min(minn,pre);
}
for(int i=;i<n;i++){
if(minn>=){
if(x){
se.insert(i+);
}
else{
se.insert(n-i);
}
}
minn-=a[i]-b[i];
}
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
rep(i,,n) cin>>a[i];
rep(i,,n) cin>>b[i];
func();
reverse(a,a+n);
reverse(b,b+n-);
func();
cout<<se.size()<<endl;
for(it=se.begin();it!=se.end();it++){
cout<<*it<<" ";
}
}
Codeforces Beta Round #61 (Div. 2)的更多相关文章
- Codeforces Beta Round #61 (Div. 2) D. Petya and His Friends 想法
D. Petya and His Friends time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Beta Round #57 (Div. 2)
Codeforces Beta Round #57 (Div. 2) http://codeforces.com/contest/61 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- screen 命令安装使用
初次接触Linux的朋友总会有个感觉:Windows平台想同时运行多个操作,执行多个程序或命令只需要打开程序即可:但在Linux中,命令行就一个,要想同时执行多个命令如何操作? 其实,只需要一个简简单 ...
- elasticSearch-DSL
DSL: query_string match match_phrase match_phrase_prefix multi_match simple_query_string term term ...
- mysql5.7.21免安装版配置步骤
1. 下载mysql5.7.21 地址https://dev.mysql.com/downloads/mysql/ 2. 解压缩 任何文件夹都行,为了避免放在系统盘,我放到了E盘,目录为E:\Prog ...
- PostgresQL 中有没有rownum这样的,显示结果集的序号
select * from (select row_number() over() as rownum,tablename from pg_tables) t where rownum<10;
- 趣味编程:静夜思(Swift版)
func verticalWriting(txt:String, offset:Int) { Dictionary(grouping: txt.enumerated(), by: {$0.0 % of ...
- 【376】COMP 9021 相关笔记(二)
Note_01 zip() itertools.zip_longest() %time Note_02 for 循环单行输出 list 技巧 迭代器 生成器 map() zip() from path ...
- Python中os模块使用方法
os模块提供了对系统环境.文件.目录等操作系统级的接口函数.本文主要描述os模块和os.path模块常用函数以及常用实例. os模块函数 os.getcwd() 获取当前工作的目录. os.listd ...
- userdel删除用户失败提示:userdel: user * is currently logged in 解决方法
操作环境 SuSE10/SuSE11 问题现象 执行userdel -rf oracle删除用户失败,提示userdel: user 'oracle' is currently logged in ...
- node-sass:npm install node-sass --save
从git上拉下来的项目,要先安装依赖, 再运行. 缺少node-sass:npm install node-sass --save
- CentOS 6.x 默认源中带了mysql-server,可以使用yum安装。
1.执行安装命令:yum install mysql-server 2.初始化数据库,使用命令1# service mysqld start 启动MSQL service mysqld stop ...