Codeforces Beta Round #61 (Div. 2)

时间:2021-03-01 18:03:56

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<<" ";
}
}