hdu 1299 Diophantus of Alexandria
来源:互联网 发布:网络搜索排名 编辑:程序博客网 时间:2024/04/27 19:15
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1299
题目大意:
求方程1/x+1/y=1/n的解的个数
分析:
1/x+1/y = 1/n 设y = n + k;
==>1/x + 1/(n+k)=1/n;
==>x = n^2/k + n;
因为x为整数,k就是n^2的约数。
/*Heal The WorldThere's a place in your heartAnd I know that it is loveAnd this place could be muchBrighter than tomorrowAnd if you really tryYou'll find there's no need to cryIn this place you'll feelThere's no hurt or sorrowThere are ways to get thereIf you care enough for the livingMake a little spaceMake a better placeHeal the worldMake it a better placeFor you and for meAnd the entire human raceThere are people dyingIf you care enough for the livingMake it a better placeFor you and for meIf you want to know whyThere's love that cannot lieLove is strongIt only cares of joyful givingIf we try we shall seeIn this bliss we cannot feelFear od dreadWe stop existing and start livingThe it feels that alwaysLove's enough for us growingSo make a better worldMake a better placeHeal the worldMake it a better placeFor you and for meAnd the entire human raceThere are people dyingIf you care enough for the livingMake a better place for you and for meAnd the dream we were conceived inWill reveal a joyful faceAnd the world we once believed inWill shine again in graceThen why do we keep strangling lifeWound this earth' crucify its soulThough it's plain to seeThis world is heavenlyBe god's glowWe could fly so highLet our spirits never dieIn my heart I feel you are all my brothersCreate a world with no fearTogether we cry happy tearsSee the nations turntheir swords into plowsharesWe could really get thereIf you cared enough for the livingMake a little spaceTo make a better placeHeal the worldMake it a better placeFor you and for meAnd the entire human raceThere are people dyingIf you care neough for the livingMake a better place for you and for meHeal the worldMake it a better placeFor you and for meAnd the entire human raceThere are people dyingIf you care neough for the livingMake a better place for you and for meHeal the worldMake it a better placeFor you and for meAnd the entire human raceThere are people dyingIf you care neough for the livingMake a better place for you and for meThere are pepole dyingIf you care enough for the living*/#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int maxn=1e7+5;typedef long long LL;bool prime[maxn];int p[maxn/10];//素数int k;//一共有多少个素数int num[1000];//素因子的个数,注意这里不要开的太大,容易超内存int cnt;//多少个素因子void isprime()//素数筛{ k=0; LL i,j;//注意long long memset(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)//素因子分解{ 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++)//n*n的个数 ans*=(2*num[i]+1); return ans;}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;}
0 0
- HDU 1299 Diophantus of Alexandria
- HDU 1299 Diophantus of Alexandria
- Hdu 1299 (Diophantus of Alexandria)
- Hdu 1299 Diophantus of Alexandria
- hdu 1299 Diophantus of Alexandria
- hdu 1299 Diophantus of Alexandria
- HDU 1299 Diophantus of Alexandria
- hdu 1299 Diophantus of Alexandria
- HDU 1299 Diophantus of Alexandria
- HDU 1299 Diophantus of Alexandria
- HDU 1299 Diophantus of Alexandria
- hdu 1299 Diophantus of Alexandria
- 【HDU】 1299 Diophantus of Alexandria
- Diophantus of Alexandria HDU
- HDU/HDOJ 1299 Diophantus of Alexandria
- HDU 1299 Diophantus of Alexandria(数论)
- HDU 1299 Diophantus of Alexandria (数论)
- hdu 1129 Diophantus of Alexandria
- JSP中四种传递参数的方法
- linux初学(十九)之系统启动详解
- 单个知识点大汇总
- 盘点那些年,被Oracle收购的公司
- linux服务器安装apache2和nodejs
- hdu 1299 Diophantus of Alexandria
- 筛选法求素数 打表
- UIView
- 【练习笔记】剑指offer-面试题3 :二维数组中的查找
- 线程间的通信(生产者与消费者)
- UVA107等比数列注意特判
- DRP问题系列——The Network Adapter could not establish the connection
- 新媒体“4U”理论
- 【NOIP2004】合唱队形题解