版本比较
题解 「MYOI-R1」幻想只因数
正文
增加 9 行删除 9 行
39 行未改动4041424344444546464748495051515253545556575859606061626364636465666768697071727071727374757639 行未改动#define lf double#define ld long doubleusing namespace std;ll n,a;ll all[114514];//记录每一个数字的答案 ll all[114514];//记录每一个数字的答案string st;ll to10(string x,ll y){//y 进制转 10 进制 ll to10(string x,ll y){//y 进制转 10 进制 ll ans=0,tmp=1; for(int i=0;i<x.length();i++){ ans+=(x[x.length()-i-1]-'0')*tmp; tmp*=y; } } return ans;}int main(){ for(int i=2;i<10;i++){ st=""; st+=(i-1)+'0'; st+='0'; while(to10(st,i)<114514){ if(!all[to10(st,i)]){//注意如果有答案了不能再进行覆盖,否则连样例 #2 都过不去 if(!all[to10(st,i)]){//注意如果有答案了不能再进行覆盖,否则连样例 #2 都过不去 all[to10(st,i)]=i; } if(st[st.length()-1]=='0')st+=(i-1)+'0';//结尾为 0 则填 i-1 else st+='0';//否则填 0 if(st[st.length()-1]=='0')st+=(i-1)+'0';//结尾为 0 则填 i-1 else st+='0';//否则填 0 } } cin>>n; while(n--){ cin>>a; if(all[a])cout<<all[a];//有答案输答案 else cout<<-1;//没答案输 -1 cout<<endl;//记得换行哦 if(all[a])cout<<all[a];//有答案输答案 else cout<<-1;//没答案输 -1 cout<<endl;//记得换行哦 } return 0;}```