Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我已经做了好几个小时了!那位高手可以指点一下,或者给几个较大的数据吧。。。。#include "stdio.h" #include "math.h" #define Eof -1 #define Max 200 void SubMore(int sub[],int result[]) { int i,ii,add=0,add_n; int tmp[Max]={0}; for(i=0;sub[i]!=Eof;i++) { if(add!=0) { tmp[add_n]+=add; add=0; } add_n=i; for(ii=0;result[ii]!=Eof;ii++) { tmp[add_n]+=sub[i]*result[ii]+add; add=tmp[add_n]/10; tmp[add_n++]%=10; } } tmp[add_n]+=add; if(add==0) tmp[add_n]=Eof; else tmp[++add_n]=Eof; for(i=0;tmp[i]!=Eof;i++) result[i]=tmp[i]; result[i]=Eof; } void Exchang(long x,int In[]) { int i=0; while(x) { In[i++]=x%10; x/=10; } In[i]=Eof; } void Jian(int k1[],int k2[]) { int i,add=0; for(i=0;k1[i]!=Eof;i++) { k2[i]+=-k1[i]+add; add =(k2[i]+10)/10-1; k2[i]-=10*add; } while(add!=0) { k2[i]+=add; add =(k2[i]+10)/10-1; k2[i]-=10*add; } } void Input(int k[]) { int i=-1; while(k[++i]!=Eof); for(i--;i!=-1;i--) printf("%d",k[i]); printf("\n"); } main() { int i,ii; int n,dev_m; long m; int num1[15]; int num2[15]; int result[Max],tmpp[Max]; scanf("%d %ld",&n,&m); ii=sqrt(m); dev_m=1; for(i=2;i<=ii;i++) { if(m%i!=0) continue; dev_m++; if(i!=m/i) dev_m++; } Exchang(m,num1); Exchang(m,result); Exchang((long)dev_m,num2); Exchang((long)dev_m,tmpp); for(i=1;i<n;i++) { SubMore(num1,result); SubMore(num2,tmpp); } Jian(tmpp,result); Input(result); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator