链接:点击打开链接
题意:1/N! = 1/X + 1/Y,给出N,求满足条件的整数解的数量。例如:N = 2,1/2 = 1/3 + 1/6,1/2 = 1/4 + 1/4。由于数量可能很大,输出Mod 10^9 + 7
代码:
#include <iostream> #include <cmath> #include <cstring> #define mod 1000000007 using namespace std; long long prime[1000005],num[1000005]; int main(){ long long i,j,k,n,sum,temp,flag,sumsum; k=0; memset(prime,0,sizeof(prime)); for(i=2;i<=1000000;i++){ if(!prime[i]) num[k++]=i; for(j=0;j<k&&num[j]*i<=1000000;j++){ prime[num[j]*i]=1; if(i%num[j]==0) break; } } while(cin>>n){ sumsum=1; for(i=0;num[i]<=n;i++){ temp=n;sum=0; while(temp){ temp/=num[i]; sum+=temp; } flag=2*sum+1; //思路详见http://blog.csdn.net/stay_accept/article/details/47188133 sumsum=(sumsum*flag)%mod; } // cout<<sumsum<<endl; cout<<((sumsum+1)%mod)*(500000004%mod)%mod<<endl; //除法取余要用逆元 } return 0; } </span>