题目链接:hdu 1299 Diophantus of Alexandria

题意:

给你一个n,让你找1/x+1/y=1/n的方案数。

题解:

对于这种数学题,一般都变变形,找找规律,通过打表我们可以发现这个答案只与这个数的因子有关。

n=a1^p1*a2^p2*...*an^pn

ans=((1+2*p1)*(1+2*p2)*...*(1+2*pn)+1)/2

 #include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=b;++i)
using namespace std; const int N=1e5+;
int primes[N],tot=;
bool vis[N];
void Euler(){
F(i,,N-){
if(!vis[i])primes[++tot]=i;
F(j,,tot){
if(i*primes[j]>N)break;
vis[i*primes[j]]=;
if(i%primes[j]==)break;
}
}
} int t,n,ans,cas; int main()
{
Euler();
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
ans=;
F(i,,tot)
{
if(primes[i]>n)break;
int cnt=;
while(n%primes[i]==)n/=primes[i],cnt++;
ans*=*cnt+;
}
if(n>)ans*=;
printf("Scenario #%d:\n%d\n\n",++cas,(ans+)/);
}
return ;
}

hdu 1299 Diophantus of Alexandria(数学题)的更多相关文章

  1. hdu 1299 Diophantus of Alexandria (数论)

    Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  2. hdu 1299 Diophantus of Alexandria

    1/x + 1/y = 1/n 1<=n<=10^9给你 n 求符合要求的x,y有多少对 x<=y// 首先 x>n 那么设 x=n+m 那么 1/y= 1/n - 1/(n+ ...

  3. hdoj 1299 Diophantus of Alexandria

    hdoj 1299 Diophantus of Alexandria 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1299 题意:求 1/x + 1/y ...

  4. 数学--数论--HDU 1299 +POJ 2917 Diophantus of Alexandria (因子个数函数+公式推导)

    Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...

  5. hdu Diophantus of Alexandria(素数的筛选+分解)

    Description Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of ...

  6. Hdu 1299

    Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  7. Diophantus of Alexandria[HDU1299]

    Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...

  8. HDU 1299 基础数论 分解

    给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...

  9. Diophantus of Alexandria

    Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...

随机推荐

  1. dpkg: error processing mysql-server (--configure): dependency problems - leaving unconfigured

    dpkg: error processing mysql-server (--configure): dependency problems - leaving unconfigured start: ...

  2. c#编写的基于Socket的异步通信系统

    c#编写的基于Socket的异步通信系统 SanNiuSignal是一个基于异步socket的完全免费DLL:它里面封装了Client,Server以及UDP:有了这个DLL:用户不用去关心心跳:粘包 ...

  3. maven 启蒙

    Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具.为了替代ANT的Apache开源项目.现在的项目越来越大.ANT已经不适用了. 1.部署m ...

  4. [转]解决MySQL出现大量unauthenticated user的问题

    最近发现两台MySQL server在中午的时候忽然(很突然的那种)发飙,不断的挂掉.重启mysql也尽是失败,看mysql的errorlog,只能看到类似如下的信息: Forcing close o ...

  5. UML六种关系

    UML六种关系 基础之上,并对其进行了扩展.在程序中是通过继承类实现的.比如狗是对动物的具体描述,在面向对象设计的时候一般把狗设计为动物的子类. 表示方法:空心三角形箭头的实线,子类指向父类 实现 概 ...

  6. Event处理

    Event处理 今天抽时间写了一部分Event处理方面的函数愈发的觉得jQuery的优秀,自己前期的想法太粗糙,造成后面这些函数参数很多,操作很很不直观,看样子是要重构的节奏,还好小伙儿伴们安慰,架构 ...

  7. 使用Guava进行函数式编程

    本文翻译自Getting Started with Google Guava这本书,如有翻译不足的地方请指出. 在这一章,我们开始注意到使用Guava进行编写代码会更加简单.我们将看看如何使用Guav ...

  8. [Windows Azure] 使用 Windows Azure 快速搭建 Redis 服务器

    [Windows Azure] 使用 Windows Azure 快速搭建 Redis 服务器   Redis相信玩开源,大数据的朋友们并不陌生,大家最熟悉的使用者就是新浪微博,微博的整体数据缓存都是 ...

  9. HTML5学习+javascript学习:打飞机游戏简介以及Model层

    本着好记性不如烂博客以及分享成功的喜悦和分享失败的苦楚,今天我来分享下一个练手项目:打飞机游戏~从小就自己想做游戏,可是一直没有机会.HTML5给了我们这个平台,这个平台可以有很多以前想都不敢想的东西 ...

  10. bat编程基本知识

    1 声明变量 ::注意=前后不要留空格.随便说一下,在bat中,连续两个冒号表示注释 set var1=test 如果要引用这个变量的话,可以这样写:%var1% 2 echo off/on echo ...