玄关
查看原帖
玄关
1412120
__Unsigned__楼主2025/1/10 20:52

样例对了,结果居然:

#include<iostream>
using namespace std;
const int MX=2147483647;
const int MN=-2147483648;
int r(int x){
    int rev=0;
    while(x!=0){
        int pop=x%10;
        x/=10;
        if(rev>MX/10||(rev==MX/10&&pop>7)) return 0;
        if(rev<MN/10||(rev==MN/10&&pop-8)) return 0;
        rev=rev*10+pop;
    }
    return rev;
}
int j(int n,int m){
    int ans=0;
    while(m!=0){
        int pop=m%n;
        m/=n;
        ans=ans*10+pop;
    }
    return r(ans);
}
int n,m,cnt;
int main(){
    cin>>n>>m;
    int ans=j(n,m);
    while(ans!=r(ans)){
        ans+=r(ans);
        cnt++;
    }
    cout<<"STEP="<<cnt;
    return 0;
}

求条玄关

2025/1/10 20:52
加载中...