Here is the problem:- https://www.interviewstreet.com/challenges/dashboard/#problem/4e14a0058572a I just have to find out total number of divisors of n!^2. For this I did prime factorization of n! and total no. of divisors = (1+2*k1)(1+2*k2).... ,where kj is exponent of j'th prime factor. My code is:-
#include<iostream>
using namespace std;
int m =0;
void pass(long long*b,long long k,long long*a,long long i)
{
if(i==1)
return;
for(long long s=0;s<k;s++)
{
if(i%b[s]==0)
{
a[b[s]]++;
m=1;
pass(b,k,a,i/2);
break;
}
}
}
int main()
{
long long n;
cin>>n;
long long a[n+1];
for(long long j=0;j<=n;j++)
a[j]=0;
long long b[50000];
long long k =0;
for(long long i=2;i<=n;i++)
{
if(i==2)
{
a[i]++;
b[k]=i;
k++;
continue;
}
m =0;
pass(b,k,a,i);
// cout<<m<<endl;
if(m==0)
{
a[i]++;
b[k] = i;
k++;
}
}
long long s=1;
for(long long i = 0;i<=n;i++)
{
if(a[i]==0)
{
continue;
}
s*=(1+2*a[i]);
//cout<<i<<" "<<a[i]<<endl;
}
cout<<s%1000007<<endl;
}
can anyone tell how to calculate s%(10^6+7) regarding this problem for very large s(10^100 range)??