fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. #define M 1000000007
  4.  
  5. typedef long long int ll;
  6.  
  7. using namespace std;
  8.  
  9. void sieve(ll n, ll b[], ll &k)
  10. {
  11. ll a[n+1];
  12. memset(a,1,sizeof(a));
  13.  
  14. a[0]=0;
  15. a[1]=0;
  16.  
  17. for(ll i = 2;i <= n/2;i++)
  18. {
  19. for(ll j = 2;j <= n/i; j++)
  20. a[i*j]=0;
  21. }
  22.  
  23. for(ll i=1;i<=n;i++)
  24. {
  25. if(a[i])
  26. {
  27. b[k++]=i;
  28. }
  29. }
  30.  
  31. return ;
  32. }
  33.  
  34. int main()
  35. {
  36. int t;
  37. cin >> t;
  38. while(t--)
  39. {
  40. ll n;
  41. cin >> n;
  42.  
  43. ll b[200];
  44. ll k = 0;
  45.  
  46. sieve(n,b,k);
  47.  
  48. ll ans = 1;
  49.  
  50. for(ll i = 0;i<k;i++)
  51. {
  52. ll x = n/b[i];
  53. while(x)
  54. {
  55. ans = ((ans%M)*(b[i]%M))%M;
  56. x = x/b[i];
  57. }
  58. }
  59.  
  60. cout << ans << endl;
  61. }
  62. return 0;
  63. }
  64.  
Runtime error #stdin #stdout #stderr 0s 3276KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_array_length'
  what():  std::bad_array_length