This question is good God. Orz Taorunz
There is a conclusion that this conclusion feels very beautiful:
$ $ans = \prod_{i=1}^{n}\varphi (i) $$
As for why, this is probably the case:
For each number $x $, the $x $ line has $x-\varphi (x) $ number is not $1$, then this line is to be eliminated $x-\varphi (x) $ times (do not forget that each row will be $1$ to eliminate once), each elimination will make $A [x][x]$ minus one, so $A [x] [x]$ will eventually become $\varphi (x) $, so that's the answer.
The complexity of the time space is $O (n) $.
1#include <cstdio>2typedefLong LongLL;3 #defineN 1000000 + 54 #defineM 100000 + 55 #defineMod 10000000076 7 intN, ans =1, Phi[n], q[m];8 9 intMain ()Ten { Onescanf"%d", &n); A for(inti =2; I <= N; i + +) - { - if(!Phi[i]) the { -Phi[i] = i-1; -q[++ q[0]] =i; - } + for(intj =1; J <= q[0] && i * q[j] <= N; J + +) - { + if(i% q[j] = =0) A { atPhi[i * Q[j]] = phi[i] *Q[j]; - Break ; - } -Phi[i * Q[j]] = phi[i] *Phi[q[j]]; - } -Ans = (LL) ans * phi[i]%Mod; in } -printf"%d\n", ans); to return 0; +}
3288_gromah
Bzoj 3288 Mato Matrix problem Solving report