Title Link: Hdu 1299 diophantus of Alexandria
Test instructions
Give you a n, let you find 1/x+1/y=1/n number of programs.
Exercises
For this kind of mathematical problem, generally change the deformation, find the law, by playing the table we can find that the answer is only related to the number of factors.
N=a1^p1*a2^p2*...*an^pn
Ans= ((1+2*P1) * (1+2*P2) *...* (1+2*PN) +1)/2
1#include <bits/stdc++.h>2 #defineF (I,A,B) for (int i=a;i<=b;++i)3 using namespacestd;4 5 Const intn=1e5+7;6 intprimes[n],tot=0;7 BOOLVis[n];8 voidEuler () {9F (I,2, N-7){Ten if(!vis[i]) primes[++tot]=i; OneF (J,1, tot) { A if(i*primes[j]>n) Break; -vis[i*primes[j]]=1; - if(i%primes[j]==0) Break; the } - } - } - + intT,n,ans,cas; - + intMain () A { at Euler (); -scanf"%d",&t); - while(t--) - { -scanf"%d",&n); -ans=1; inF (I,1, tot) - { to if(primes[i]>n) Break; + intCnt=0; - while(n%primes[i]==0) n/=primes[i],cnt++; theans*=2*cnt+1; * } $ if(n>1) ans*=3;Panax Notoginsengprintf"Scenario #%d:\n%d\n\n", ++cas, (ans+1)/2); - } the return 0; +}
View Code
HDU 1299 Diophantus of Alexandria (maths problem)