The main idea:--I can't see it myself.
A joke--so much to tell what is φ and μ---
But not normal φ and μ, some variants--
The newly defined φ (1) = 0, the newly defined μ only computes odd prime numbers, and the number with the 2 factor is zero for the μ value.
We first find the first and second questions, that is, the μ value is not equal to 0 of the part
Because of the definition of μ, the μ value is not equal to 0 when and only if the number of times per factorization is 1 times
So we enumerate the portions of each singular prime number calculation plus the sum of the φ values after this odd prime.
Since φ is an integrable function, the first two questions can be solved in O (n) time
The third question can use the total answer to lose the first two answers
Because Σ[d|n]φ (d) =n, so the total answer is m-1 (this question 1 is not the other number of factors, minus 1)
The answer to the first two questions with M-1 is the answer to the third question.
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define M 10100# Define MOD 10000using namespace std;struct abcd{int p,a;friend istream& operator >> (IStream &_,ABCD &x) {scanf ("%d%d", &x.p,&x.a); return _;}} Prime_factors[1010];int n,m,ans1,ans2,ans3;int quick_power (int x,int y) {int re=1;while (y) {if (y&1) (re*=x)%=MOD; x*=x)%=mod;y>>=1;} return re;} int main () {int i;cin>>n;for (i=1;i<=n;i++) cin>>prime_factors[i];for (i=1;i<=n;i++) {if (prime_ factors[i].p==2) Continue;int temp1= (ans1+ans2* (prime_factors[i].p-1))%mod;int temp2= (ans2+ (ans1+1) * (prime_ factors[i].p-1))%mod;ans1=temp1;ans2=temp2;} M=1;for (i=1;i<=n;i++) (M*=quick_power (PRIME_FACTORS[I].P,PRIME_FACTORS[I].A))%=mod; (ans3= (M-1)-ans1-ans2+MOD %=mod;cout<<ans1<<endl<<ans2<<endl<<ans3<<endl;return 0;}
Bzoj 1408 NOI2002 Robot number theory