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 |
输入1 1应该输出什么?不应该是1么?怎么过的程序都输出0啊?(附我的不AC代码……)#include <iostream> #include <cmath> using namespace std; typedef long long i64; i64 pf[110000],pfNum,mn,d[110000],n,m,t,change; void getChange(i64 btm,i64 now,i64 top) { i64 get=m,i; if(now==top) { for(i=0;i<top;i++) get/=d[i]; change+=i64(pow(double(get),double(n))); } else for(i=btm;i<pfNum;i++) d[now]=pf[i],getChange(i+1,now+1,top); } int main() { i64 i,ans,mm; while(cin>>n>>m) { pfNum=0; mm=m; for(i=2;i*i<=mm;i++) { if(mm%i==0) { while(mm%i==0) mm/=i; pf[pfNum++]=i; } } if(mm!=1) pf[pfNum++]=mm; ans=mn=i64(pow(double(m),double(n))); for(i=0;i<pfNum;i++) { change=0; getChange(0,0,i+1); if(i%2) ans+=change; else ans-=change; } cout<<ans<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator