The topic is: Given A1,A2,..., an, ask
Since φ is an integrable function, we can decompose the i1i2...in into factorization, and for each factorization to be discussed separately, the quadrature can be
Factorization each a decomposition, assuming that the number of times that a prime p is decomposed is bi in each AI, then P's contribution to the answer is
So the p^j maintain a prefix and, directly calculate can
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define MOD 1000000007using namespace std;struct abcd{int p,a; BOOL operator < (const ABCD &x) const {if (P!=X.P) return p<x.p; Return a<x.a; }}prime_factors[1001001];int N,tot;long long ans=1;void decomposition (int x) {int i; for (i=2;i*i<=x;i++) if (x%i==0) {prime_factors[++tot].p=i; while (x%i==0) prime_factors[tot].a++,x/=i; } if (x^1) prime_factors[++tot].p=x,prime_factors[tot].a=1;} Long Long quick_power (long long X,long long y) {long long re=1; while (y) {if (y&1) (re*=x)%=mod; (x*=x)%=mod;y>>=1; } return re;} void Calculate (int l,int r) {Static long long sum[30]; Long Long P=PRIME_FACTORS[L].P; Long Long re=1; int i; Sum[0]=1; for (i=1;i<=prime_factors[r].a;i++) Sum[i]=sum[i-1]*p%mod; for (i=1;i<=prime_factors[r].a;i++) (sum[i]+=sum[i-1])%=mod; For (i=l;i<=r;i++) (re*=sum[prime_factors[i].a])%=mod; re--;(Re*=quick_power (p,mod-2))%=mod; (Re*=p-1,++re)%=mod; (Ans*=re)%=mod;} int main () {int i,x; cin>>n; for (i=1;i<=n;i++) {scanf ("%d", &x); Decomposition (x); } sort (prime_factors+1,prime_factors+tot+1); for (i=1;i<=tot;i++) {static int last; if (i==tot| | PRIME_FACTORS[I].P!=PRIME_FACTORS[I+1].P) Calculate (last+1,i), last=i; } cout<< (Ans%mod+mod)%mod<<endl; return 0;}
Bzoj 3560 Dzy Loves Math V number theory