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 |
为什么哇?跟AC的程序对比了100000组数据都没问题。。。#define maxn 10000 #include <iostream> using namespace std; typedef struct pf{ int pN; int exponent; }primeFactor; primeFactor F[40]; int pFtop; //integer decomposition void factorDecomp(int n) { pFtop=0; for(int i=2;i*i<=n;i++)if(!(n%i)){ F[pFtop].pN=i; F[pFtop].exponent=0; while(0==(n%i)) { n/=i; F[pFtop].exponent++; } pFtop++; } if(n>1){ F[pFtop].pN=n; F[pFtop].exponent=1; pFtop++; } } #define mod 9901 //prime base, exponent //find 1+p+p^2+...+p^epn (mod mod) int divSum(int pb, int epn) { int res=1,tmp=pb; for(int i=1;i<=epn;i++){ res+=tmp; res%=mod; tmp*=pb; tmp%=mod; } return res; } void solve(int b){ int i,sum=1; for(i=0;i<pFtop;i++){ F[i].pN%=mod; F[i].exponent=(F[i].exponent*b)%(mod-1); } for(i=0;i<pFtop;i++){ sum*=divSum(F[i].pN, F[i].exponent); sum%=mod; } cout<<sum<<endl; } int main(){ int A,B; while(cin>>A>>B) { if(A<2||B==0) { if(A<1) cout<<0<<endl; else cout<<1<<endl; continue; } factorDecomp(A); solve(B%(mod-1)); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator