当前位置: 代码迷 >> 综合 >> Educational Codeforces Round 51 (Rated for Div. 2)
  详细解决方案

Educational Codeforces Round 51 (Rated for Div. 2)

热度:69   发布时间:2023-11-02 20:58:38.0

在这过程中想出了三道题,感觉前三题难度还可以。

A.Vasya And Password X3539

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char str[110];
int main(){int t;scanf("%d",&t);while(t--){//cout<<"*"<<endl;int cnt1=0,cnt2=0,cnt3=0;//getchar();getchar();scanf(" %s",str);int len=strlen(str);for(int i=0;i<len;i++){if(str[i]>='0'&&str[i]<='9') cnt1++;else if(str[i]>='a'&&str[i]<='z') cnt2++;else if(str[i]>='A'&&str[i]<='Z') cnt3++;}if(cnt1&&cnt2&&cnt3) printf("%s\n",str);else if(cnt1==0&&cnt2==0){str[0]='1';str[1]='a';printf("%s\n",str);}else if(cnt2==0&&cnt3==0){str[0]='A';str[1]='a';printf("%s\n",str);}else if(cnt1==0&&cnt3==0){str[0]='1';str[1]='A';printf("%s\n",str);}else if(cnt1==0){if(cnt2>1&&cnt3>1){str[0]='1';}else if(cnt2==1){for(int i=0;i<len;i++){if(str[i]>='A'&&str[i]<='Z'){str[i]='1';break;}}}else{ //cnt3==1for(int i=0;i<len;i++){if(str[i]>='a'&&str[i]<='z'){str[i]='1';break;}}}printf("%s\n",str);}else if(cnt2==0){if(cnt1>1&&cnt3>1){str[0]='a';}else if(cnt1==1){for(int i=0;i<len;i++){if(str[i]>='A'&&str[i]<='Z'){str[i]='a';break;}}}else{ //cnt3==1for(int i=0;i<len;i++){if(str[i]>='0'&&str[i]<='9'){str[i]='a';break;}}}printf("%s\n",str);}else if(cnt3==0){if(cnt1>1&&cnt2>1){str[0]='A';}else if(cnt2==1){for(int i=0;i<len;i++){if(str[i]>='0'&&str[i]<='9'){str[i]='A';break;}}}else{ //cnt1==1for(int i=0;i<len;i++){if(str[i]>='a'&&str[i]<='z'){str[i]='A';break;}}}printf("%s\n",str);}}return 0;
}

B.Relatively Prime Pairs X4036

#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;int main(){ll l,r;scanf("%lld%lld",&l,&r);printf("YES\n");ll cnt=(r-l+1)/2;for(ll i=l,j=0;j<cnt;j++,i+=2){printf("%lld %lld\n",i,i+1);}return 0;
}

C.Vasya and Multisets X2267

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=110;
int a[maxn],num[maxn];int main(){int n;scanf("%d",&n);for(int i=0;i<n;i++){scanf("%d",&a[i]);num[a[i]]+=1;}string ans="";int cnt=0;for(int i=0;i<n;i++){if(num[a[i]]==1) cnt++;}//cout<<"cnt="<<cnt<<endl;if(cnt%2==1){int res=0;bool flag=false;for(int i=0;i<n;i++){if(num[a[i]]==1&&res<cnt/2){ans+='A';// cout<<"*"<<endl;res++;}else if(!flag&&num[a[i]]>2){ans+='A';flag=true;}else ans+='B';}if(flag){puts("YES");cout<<ans<<endl;}else   puts("NO");}else{int res=0;for(int i=0;i<n;i++){if(num[a[i]]==1&&res<cnt/2){ans+='A';// cout<<"*"<<endl;res++;}else ans+='B';}puts("YES");cout<<ans<<endl;//puts(ans);}return 0;
}

D.Bicolorings X1354

E. Vasya and Big Integers X34

F. The Shortest Statement X104

G. Distinctification X1

  相关解决方案