标签:limit art follow ace this input std des space
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4348 Accepted Submission(s): 1934
1 #include<iostream> 2 #include<string> 3 using namespace std; 4 int main() 5 { 6 int n,i,j,a,b,c; 7 int fz[23]={0},fm[23]={0},zs[23]={0}; 8 int sum=1, gbs=1; 9 zs[1]=1; 10 for(i=2; i<=22; i++) 11 { 12 for(j=1; j<=i; j++) 13 { 14 if(j*gbs%i==0) 15 { 16 gbs=j*gbs; 17 sum=j*sum+gbs/i; 18 fm[i]=gbs/i; 19 zs[i]=sum/fm[i]; 20 fz[i]=sum%fm[i]; 21 a=fm[i]; 22 b=fz[i]; 23 while(b!=0) 24 { 25 c=a%b; 26 a=b; 27 b=c; 28 } 29 fz[i]=fz[i]/a; 30 fm[i]=fm[i]/a; 31 break; 32 } 33 } 34 } 35 while(cin>>i) 36 { 37 if(fz[i]) 38 { 39 int lin=zs[i], len=2, num=1; 40 while(lin/10) 41 { 42 lin/=10; 43 len++; 44 } 45 lin=fm[i]; 46 while(lin/10) 47 { 48 lin/=10; 49 num++; 50 } 51 cout<<string(len, ‘ ‘)<<fz[i]<<endl; 52 cout<<zs[i]<<‘ ‘<<string(num, ‘-‘)<<endl; 53 cout<<string(len, ‘ ‘)<<fm[i]<<endl; 54 } 55 else 56 { 57 cout<<zs[i]<<endl; 58 } 59 } 60 return 0; 61 }
标签:limit art follow ace this input std des space
原文地址:https://www.cnblogs.com/zhaopeng938/p/9418703.html