⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 persistent numbers.txt

📁 以前ACM在哈工程HRBEU做的一些简单题目
💻 TXT
字号:
#include "iostream.h"
#include "string.h"
#include "memory.h"
char s[1001];
int a[1000],b[1000],ans[3000],len,len1,n;
void div(int a[],int d)
{
     int x,t=0;
     memset(b,0,sizeof(b));
     for(int i=len1;i<len;i++)
     {
        x=t*10+a[i];
        b[i]=x/d;
        t=x%d;
     }
     if(t==0)
     {
             memcpy(a,b,sizeof(b));
             while(b[len1]==0)len1++;
             ans[n++]=d;
             div(a,d);
     }
}
     

int main()
{
    int i,j;
      while(1)
     {
       cin>>s;
       if(s[0]=='-')break;
       if(strcmp(s,"0")==0){cout<<"10"<<endl;continue;}
       if(strcmp(s,"1")==0){cout<<"11"<<endl;continue;}
       memset(ans,0,sizeof(ans));
       len=strlen(s);
       for(i=0;i<len;i++)a[i]=s[i]-48;
       len1=0;
       n=0;
       for(j=9;j>=2;j--)div(a,j);
       if(len!=len1+1)cout<<"There is no such number."<<endl;
       else 
       {
            if(len==1)cout<<"1";
          while(n>0){cout<<ans[n-1];n--;}
           cout<<endl;
       }
     }
     return 0;
} 
       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -