其他分享
首页 > 其他分享> > Codeforces Round #581 (Div. 2)

Codeforces Round #581 (Div. 2)

作者:互联网

Codeforces Round #581 (Div. 2)

A

# include <bits/stdc++.h>
using namespace std;

int main()
{
string s;
cin>>s;
int len=s.size();
int ans=0;
int flag=0;
for(int i=0;i<len;i++){
if(s[i]=='1'){
if(ans==0){
ans=(len-i)/2;
if((len-i-1)%2==0) flag=1;
}else if(flag){
ans++;
break;
}else break;
}
}
printf("%d\n",ans);
return 0;
}

B

# include <bits/stdc++.h>
using namespace std;

int main()
{
int n,l,r;
scanf("%d%d%d",&n,&l,&r);
int a=1;
int minn=0;
for(int i=1;i<=l;i++){
minn+=a;
a=a*2;
}
minn+=(n-l);
int b=1;
int maxx=0;
for(int i=1;i<=r;i++){
maxx+=b;
b=b*2;
}
b=b/2;
maxx+=(n-r)*b;
printf("%d %d\n",minn,maxx);
return 0;
}

C

# include <bits/stdc++.h>
using namespace std;

const int MAXN=110;
const int MAXX=1e6+100;
int m[MAXN][MAXN];
int p[MAXX];
int main()
{
int n;
scanf("%d",&n);
memset(m,MAXX,sizeof(m));
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char aaaa;
aaaa=getchar();
if(aaaa=='1') m[i][j]=1;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
m[i][j]=min(m[i][j],m[i][k]+m[k][j]);
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cout<<m[i][j]<<" ";
}
cout<<endl;
}

int m;
scanf("%d",&m);
for(int i=1;i<=m;i++) scanf("%d",&p[i]);

return 0;
}

D

# include <bits/stdc++.h>
using namespace std;

int main()
{
string s;
long long ans=0;
cin>>s;
for(int i=s.size()-1;i>=0;i--){
if(s[i]=='0') ans++;
else{
if(ans) ans--;
else s[i]='0';
}
}
cout<<s<<endl;
return 0;
}



标签:maxx,minn,581,int,namespace,Codeforces,ans,Div,main
来源: https://www.cnblogs.com/fengzlj/p/15940940.html