标签:eof sub lang enter names closed ems opened 描述
99
81 8
注意!!!!是非零数字相乘!!
1 #include <iostream> 2 #include<string> 3 #include<cstring> 4 using namespace std; 5 int n,a[100005],b[100005],c[100005]; 6 string fun_multi(string s,char t) 7 { 8 string ans; 9 if(s=="0"||t==‘0‘) 10 { 11 return "0"; 12 } 13 memset(c,0,sizeof(c)); 14 int len1=s.size(),w=0,n=t-‘0‘; 15 for(int i=len1-1;i>=0;i--) a[len1-i-1]=s[i]-‘0‘; 16 for(int i=0;i<len1;i++) 17 { 18 c[i]=a[i]*n+w; 19 w=c[i]/10; 20 c[i]%=10; 21 } 22 if(w) c[len1]=w,len1++; 23 // while(!c[len1]) len1--; 24 for(int i=len1-1;i>=0;i--) 25 ans+=c[i]+‘0‘; 26 return ans; 27 } 28 string fun(string s) 29 { 30 string ans="1",t; 31 int len=s.size(); 32 for(int i=0;i<len;i++) 33 { 34 if(s[i]==‘0‘) continue; 35 ans=fun_multi(ans,s[i]); 36 // if(ans=="0") 37 // break; 38 // cout<<ans<<endl; 39 } 40 return ans; 41 } 42 int main() 43 { 44 string s; 45 cin>>s; 46 47 // cout<<s<<endl; 48 int len=s.size(); 49 if(len==1) { 50 cout<<s<<endl; 51 return 0; 52 } 53 while(len!=1) 54 { 55 s=fun(s); 56 cout<<s<<endl; 57 len=s.size(); 58 } 59 // cout<<s<<endl; 60 return 0; 61 }
标签:eof sub lang enter names closed ems opened 描述
原文地址:https://www.cnblogs.com/scott527407973/p/9323102.html