Zjc20120331 @ 2023-04-04 20:01:20
rt
#include <bits/stdc++.h>
using namespace std;
int c[130];
bool hui(long long x){
return (x == hui(x));
}
long long fan(long long x){
long long sum = 0;
while (x){
sum = sum*10+x%10;
x /= 10;
}
return sum;
}
int main(){
c['1'] = 1;
c['2'] = 2;
c['3'] = 3;
c['4'] = 4;
c['5'] = 5;
c['6'] = 6;
c['7'] = 7;
c['8'] = 8;
c['9'] = 9;
c['0'] = 0;
c['a'] = 10;
c['b'] = 11;
c['c'] = 12;
c['d'] = 13;
c['e'] = 14;
c['f'] = 15;
int jz;
string s;
cin >> jz >> s;
long long n = 0, sum = 1;
for (int i = 0; i <= s.size(); i++){
n += sum*c[s[i]];
sum *= jz;
}
for (int i = 1; i <= 30; i++){
if (hui(i)){
printf("STEP=%d\n", i);
return 0;
}
n += fan(n);
}
printf("Impossible!\n");
return 0;
}
by Rieman_sum @ 2023-04-04 20:05:18
高精度
by qwertim @ 2023-04-04 20:16:06
你的hui
函数永远不会结束
by Fated_Shadow @ 2023-04-04 20:31:17
hui
函数过于鬼畜,不会结束。
for (int i = 0; i <= s.size(); i++)
改为 for (int i = 0; i < s.size(); i++)
。
会爆 long long,开高精度。
没有用进制运算
总结:全是锅
by Fated_Shadow @ 2023-04-04 20:31:34
@Zjc20120331