Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1299
Main topic:
To find the number of solutions of 1/x+1/y=1/n equation
Analysis:
1/x+1/y = 1/n Set y = n + k;
==>1/x + 1/(n+k) =1/n;
==>x = n^2/k + N;
Because X is an integer, K is the approximate number of n^2.
/*heal the Worldthere ' s a placeinchYour Heartand I know that it's loveand this place could be muchbrighter than TomorrowandifYou reallyTryYou ' ll find there ' s no need toCryin this place you ' ll FeelThere ' s no hurtorSorrowthere is ways toGet Thereif Enough forThe Livingmake a little spacemake a better placeheal the worldmake it a better placefor you and forMeand the entire human racethere is people dyingif you care enough forThe livingmake it a better placefor you and forMeif you want toKnow Whythere ' s love, cannot lielove is strongit only cares ofJoyful Givingif WeTryWe shall seein this bliss we cannot feelfear od dreadwe stop existing andStart Livingthe it feels that Alwayslove ' s enough forUS growingso make a better worldmake a better placeheal the worldmake it a better placefor and forMeand the entire human racethere is people dyingif you care enough forThe Livingmake a better place forYou and forMeand The dream we were conceivedinchWould reveal a joyful faceand the world we once believedinchWould shine againinchGracethen why DoWe keep strangling lifewound this earth ' crucify its soulthough it ' s plain toSeethis World is Heavenlybe God's glowwe could fly so highlet we spirits never diein my heart I feel you're all my broth Erscreate a World withNo feartogether we cry happy tearssee the Nations Turntheir swords into plowshareswe could really get thereif you cared en Ough forThe Livingmake a little spaceto make a better placeheal the worldmake it a better placefor and forMeand the entire human racethere is people dyingif you care Neough forThe Livingmake a better place forYou and forMeheal the Worldmake it a better placefor you and forMeand the entire human racethere is people dyingif you care Neough forThe Livingmake a better place forYou and forMeheal the Worldmake it a better placefor you and forMeand the entire human racethere is people dyingif you care Neough forThe Livingmake a better place forYou and forMethere is pepole dyingif you care enough forThe living*/#include <iostream> #include <cstring> #include <cstdio>usingnamespaceStd;const int maxn=1e7+5; typedef long LONG Ll;bool prime[maxn];int p[maxn/Ten];//Primeint k;//How many primes are there altogether?int num[ +];//The number of factors, note that this does not open too large, easy to ultra-memoryint cnt;//How many vegetarian factorsvoidIsPrime ()//Prime sieve{k=0; LL i,j;//Note long longmemset (Prime,true, sizeof (prime)); for(LL i=2; i<maxn; i++) {if(Prime[i]) {p[k]=i; k++; for(j=i*i; j<maxn; j+=i) prime[j]=false; }}}ll Fenjie (LL N)//Factor decomposition{cnt=0; LL ans=1; memset (NUM,0, sizeof (num)); for(int i=0; p[i]*p[i]<=n&&i<k; i++) {if(n% p[i] = =0) {//fac[cnt]=p[i]; while(n%p[i]==0) {num[cnt]++; N/=p[i]; } cnt++; } }if(n>1) {//fac[cnt]=n;num[cnt++]=1; } for(int i=0; i<cnt;i++)Number of//n*nAns*= (2*num[i]+1);returnAns;} int main () {isprime (); int m,cas=1; scanf"%d", &m); while(m--) {LL x; scanf"%lld", &x); printf"Scenario #%d:\n%lld\n\n", cas++, (Fenjie (x) +1)/2); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 1299 Diophantus of Alexandria