Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <cmath>
- #include <fstream>
- #define pb push_back
- #define fs first
- #define sc second
- using namespace std;
- using ll=long long;
- using ld=long double;
- const ll maxn = 1e7 + 2;
- const ll mod = 1e9 + 7;
- typedef pair<ll,ll> LL;
- ll t, n, p;
- ll limit = 1e7;
- bool b[maxn];
- vector<LL> nt;
- void split(ll n)
- {
- for(ll i = 0; nt[i].fs <= n; i++)
- {
- if(i == p) break;
- ll x = nt[i].fs;
- ll y = x;
- while(y <= n)
- {
- nt[i].sc += n/y;
- y *= x;
- }
- }
- }
- ll nhan(ll x,ll y)
- {
- if(y == 0) return 1;
- ll t = nhan(x,y/2);
- if(y % 2 == 0) return(t%mod * t%mod)%mod;
- else return(t%mod * t%mod * x%mod)%mod;
- }
- int main()
- {
- //freopen(taskname".INP", "r", stdin);
- //freopen(taskname".OUT", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- for(ll i = 2; i <= limit; i++)
- {
- if(!b[i])
- {
- for(ll j = i * 2;j <= limit; j += i) b[j] = true;
- }
- }
- for(ll i = 2; i <= limit; i++)
- {
- if (!b[i]) nt.push_back(make_pair(i,0));
- }
- p = nt.size();
- cin >> t;
- for(ll i = 1; i <= t; i++)
- {
- ll res = 1;
- cin >> n;
- for(ll j = 0; j < p; j++) nt[j].sc = 0;
- split(n);
- for(ll j = 0; nt[j].fs <= n; j++)
- {
- if(j == p) break;
- res *= nhan(nt[j].fs,nt[j].sc - nt[j].sc % 2);
- res %= mod;
- }
- cout<<res % mod<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement