Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int lim = 99999999;
- const int MOD = 1e9 + 7;
- long long POW(int x , int y){
- if(y == 0) return 1;
- long long ret = POW(x , y/2);
- ret *= ret; ret %= MOD;
- if(y % 2) ret *= x , ret %= MOD;
- return ret;
- }
- map < int , int > facts;
- int main(){
- int n;
- scanf("%d",&n);
- for(int j = 1 ; j <= n ; j++){
- int x;
- scanf("%d",&x);
- for(int i = 2 ; i * i <= x ; i++){
- while(x % i == 0){
- facts[i]++;
- x /= i;
- }
- }
- if(x > 1) facts[x]++;
- }
- long long ret = 1;
- bool ok = 1;
- for(auto pp : facts){
- if(pp.second % n == 0){
- pp.second /= n;
- for(int j = 0 ; j < pp.second ; j++)
- ret *= pp.first;
- }
- else ok = 0;
- }
- if(ok){
- puts("justdoit");
- // cout<<ret<<endl;
- }
- else {
- // puts("3tees");
- ret = 1;
- for(auto pp : facts){
- pp.second %= (n + 1);
- int aa = n + 1 - pp.second;
- aa %= (n + 1);
- ret *= POW(pp.first , aa);
- ret %= MOD;
- }
- cout<<ret<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement