poj3910欧拉函数的矩阵应用

//有点问题
#include  
#include 
const int mo = 1000000007;
long long i, n, j, a[101000], bj[101000], k, tot, ans;
int main()
{
    //freopen("worry.in", "r", stdin);
    //freopen("worry.out", "w", stdout);
    while(1)
    {
        scanf("%I64d", &n);
    for (bj[a[tot = 1] = i = 2] = 1; i <= 100000; ++i)
    {
if (!bj[i]) bj[i] = 1, a[++tot] = i;
for (j = 1; j <= tot && a[j] * i <= 100000; ++j)
{
   bj[a[j] * i] = 1;
   if (i % a[j] == 0) break;
}
    }
    for (i = ans = 1; i <= n; ++i)
    {
scanf("%I64d", &k); int h = k;
for (j = 1; j <= tot && a[j] * a[j] <= h; ++j)
   for (int ok = 1; k % a[j] == 0;)
   {
if (ok) ans = ans * (a[j] - 1) % mo;
else ans = ans * a[j];
k /= a[j];
ok = 0;
   }
if (k > 1) ans = ans * (k - 1) % mo;
    }
    printf("%I64d\n", ans);
    }
    return 0;
}

你可能感兴趣的:(poj3910欧拉函数的矩阵应用)