1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; string s1,s2,s3; int a[1005]; void xx(string s,int ss) { memset(a,0,sizeof(a)); int si=s.size(); for(int i=0;i<si/2;i++) swap(s[i],s[si-1-i]); for(int i=0;i<si;i++) { a[i]+=(s[i]-'0')*ss; a[i+1]+=a[i]/10; a[i]=a[i]%10; } int q=0; if(a[si]!=0) si++; string s3=""; swap(s3,s2); for(int i=si-1;i>=q;i--) s2+=char(a[i]+'0'); } int main() { cin>>s1; if(s1.size()==1)cout<<s1; else for(;s1.size()!=1;) { s2+=s1[0]; for(int i=1;i<s1.size();i++)if(s1[i]!='0')xx(s2,s1[i]-'0'); swap(s1,s2); string fc=""; swap(fc,s2); } cout<<s1; return 0; }Pascal :
var m,n:longint; i,k,j,s:longint; begin readln(n); s:=n; k:=n; m:=1; while k>9 do begin while s<>0 do begin j:=s mod 10; s:=s div 10; m:=m*j; k:=m; end; s:=k; m:=1; end; write(k); end.Python :
# coding=utf-8 n=int(input()) while True: s=1 while n>0: t=n%10 s*=t n//=10 if s<10: print(s) break else: n=s
- 1
Information
- ID
- 17055
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By