GCD Determinant 解题报告
PreviousPKU POJ 3757 Simple Distributed storage system 解题报告NextSoutheastern European 2008 Sky Code 解题报告
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
1
12
4#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
const long mod = 1000000007;
long x[1005];
long eular(long n)
{
long res = 1, i;
for(i = 2; i * i <= n; i ++)
{
if(n % i == 0)
{
n /= i;
res *= (i - 1);
while(n % i == 0)
n /= i, res *= i;
}
}
if(n > 1)
res *= n - 1;
return res;
}
int main()
{
int n, i;
long res;
while(scanf("%d", &n) != EOF)
{
res = 1;
for(i = 0; i < n; i ++)
scanf("%ld", &x[i]);
sort(x, x + n);
for(i = 0; i < n; i ++)
res = ((long long)res * (long long)eular(x[i])) % mod;
printf("%ld\n", res);
}
return 0;
}