wangminyuan @ 2024-09-13 21:14:03
#include<bits/stdc++.h>
using namespace std;
int main()
{
int bite,i=0,ans=0;
string n;
bool f=false;
cin>>bite>>n;
while(n.size()!=i)
{
ans*=bite;
ans+=n[i]-'0';
i++;
}
int s=ans,x=0;
for(int i=0;i<30;i++)
{
s+=s+s/10+s%10*10;
while(s>0)
{
x=x*10+s%10;
s=s/10;
}
if(x==ans)
{
cout<<"STEP="<<i<<endl;
f=true;
break;
}
}
if(!f)
{
cout<<"Impossible!"<<endl;
}
return 0;
}
by wangminyuan @ 2024-09-13 21:15:50
哪位大佬能改改(洛谷新手请谅解),改的好人一生平安。
by yueyifan @ 2024-09-14 22:51:34
看题解 思路错了
by yueyifan @ 2024-09-14 22:52:39
点我
by yueyifan @ 2024-09-14 22:55:54
这个高精度
by ghly @ 2024-09-20 21:00:56
#include "bits/stdc++.h"
using namespace std;
int n;
string jia(string a,string b)
{
int i=0,j=0,k=0,x=0,s[1001]={0},ss[1001]={0},c[1001]={0};
while(a.length()<b.length())a="0"+a;
while(b.length()<a.length())b="0"+b;
for(i=a.length()-1;i>=0;i--)s[a.length()-i-1]=a[i]-48;
for(i=b.length()-1;i>=0;i--)ss[a.length()-i-1]=b[i]-48;
for(i=0;i<a.length();i++){
c[i]+=s[i]+ss[i];
c[i+1]=c[i]/n;
c[i]=c[i]%n;
}
x=a.length();
if(c[i]>0)i++;
string ans="";
for(j=i-1;j>=0;j--)ans+=char(c[j]+48);
return ans;
}
int main(void)
{
string s,t;
cin>>n>>s;
for(int i=0;i<s.length();i++)
{
if(s[i]<='Z'&&s[i]>='A')s[i]=s[i]-'A'+'0'+10;
}
t=s;
reverse(t.begin(),t.end());
if(s==t)return puts("STEP=0"),0;
int step=0;
while("MOK_IS_MY_GF"&&step<=30)
{
step++;
s=jia(s,t);
t=s;
reverse(t.begin(),t.end());
if(t==s)return printf("STEP=%d\n",step),0;
}
cout<<"Impossible!\n";
return 0;
}