Codeforces Round #555 (Div. 3) AB

时间:2022-07-04 08:53:31

A:    http://codeforces.com/contest/1157/problem/A

题意:每次加到10的整数倍之后,去掉后面的0,问最多有多少种可能。

 #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set> using namespace std; int main()
{
ios::sync_with_stdio(false);
cin.tie();
cout.tie(); int n;
set<int> si;
while(cin>>n){
si.clear();
si.insert(si.end(),n);
while(n!=){
n++;
while(n%==){
n/=;
}
si.insert(si.end(),n);
}
n=;
si.insert(si.end(),n);
while(n!=){
n++;
while(n%==){
n/=;
}
si.insert(si.end(),n);
}
cout<<si.size()<<endl;
}
return ;
}

B:   http://codeforces.com/contest/1157/problem/B

题意:有一个很长的字符串,和1-9之间数字的映射关系。问修改其中一段得到的最大的串是什么。(可以进行0次或1次修改)

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set> using namespace std; int main()
{
ios::sync_with_stdio(false);
cin.tie();
cout.tie(); int n;
string s1;
int mapp[];
while(cin>>n){
cin>>s1; string s3(s1);
for(int i=;i<;i++){
cin>>mapp[i];
}
for(int j=;j<s1.size();j++){
string s2(s1);
for(int i=j;i<s1.size();i++){
char t=mapp[s1[i]-'']+'';
if(t>=s1[i]){
s2[i]=mapp[s1[i]-'']+'';
}else{
break;
}
}
if(s2>s3) s3=s2;
}
cout<<s3<<endl;
}
return ;
}