洛谷 P1445 [Violet]樱花
1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<vector> 5 using namespace std; 6 #define fi first 7 #define se second 8 #define mp make_pair 9 #define pb push_back 10 typedef long long ll; 11 typedef unsigned long long ull; 12 typedef pair<int,int> pii; 13 #define md 1000000007 14 int num[1001000]; 15 bool vis[1001000]; 16 int d[1001000]; 17 int n; 18 ll ans=1; 19 int main() 20 { 21 ll i,j; 22 scanf("%d",&n); 23 //n=1000000; 24 for(i=2;i<=n;i++) d[i]=i; 25 for(i=2;i<=n;i++) 26 if(!vis[i]) 27 for(j=i;j<=n;j+=i) 28 { 29 vis[j]=1; 30 while(d[j]%i==0) d[j]/=i,num[i]++; 31 } 32 for(i=1;i<=n;i++) num[i]*=2,ans=ans*(num[i]+1)%md; 33 printf("%lld",ans); 34 return 0; 35 }