hdu 1299 Diophantus of Alexandria(数学题)
题目链接: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(数学题)的更多相关文章
- hdu 1299 Diophantus of Alexandria (数论)
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- 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+ ...
- hdoj 1299 Diophantus of Alexandria
hdoj 1299 Diophantus of Alexandria 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1299 题意:求 1/x + 1/y ...
- 数学--数论--HDU 1299 +POJ 2917 Diophantus of Alexandria (因子个数函数+公式推导)
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...
- hdu Diophantus of Alexandria(素数的筛选+分解)
Description Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of ...
- Hdu 1299
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- Diophantus of Alexandria[HDU1299]
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- HDU 1299 基础数论 分解
给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...
- Diophantus of Alexandria
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...
随机推荐
- 动动手,写个knockout的分页模板
最近一个项目用ASP.NET + knockout开发,很多列表页面都带分页,于是就有了写一个公共的分页模板的想法. 先把template写好: <script type="text/ ...
- 无法识别的配置节 applicationSettings
在.NETFramework2.0中,如果发布的虚拟目录程序引用了外部的webservice访问接口,配置文件会出现下边的applicationSettings节点,如 但是访问应用程序时候,可能会出 ...
- Load ContextCLR 探测
目录 背景Load ContextCLR 探测过程弱签名程序集的探测过程强签名程序集的探测过程Default ContextLoad-From ContextNo ContextRelfection- ...
- 使用NeatUpload控件实现ASP.NET大文件上传
使用NeatUpload控件实现ASP.NET大文件上传 一般10M以下的文件上传通过设置Web.Config,再用VS自带的FileUpload控件就可以了,但是如果要上传100M甚至1G的文件就不 ...
- VS调试技巧与快捷键&&VS快捷键
VS调试技巧与调试快捷键 1.添加断点或取消断点:F9(或者点击代码行最左边的灰色行) 2.调试:F10逐过程(不进入函数内部,直接获取函数运行结果) F11逐语句(会进入函数),如果想跳出函数 ...
- 教你用Perl 实现Base64编码
在用脚本后台发送邮件时,需要将html的内容转换成Base64编码的形式,这样邮件客户端会自动对Base64编码的内容进行解码,还原成原来的内容. Base64.pl: #!/usr/bin/perl ...
- Area 使用
[ASP.NET MVC 小牛之路]08 - Area 使用 ASP.NET MVC允许使用 Area(区域)来组织Web应用程序,每个Area代表应用程序的不同功能模块.这对于大的工程非常有用,Ar ...
- h5 localStorage存储大小(转)
摘要 HTML5 的本地存储 API 中的 localStorage 与 sessionStorage 在使用方法上是相同的,区别在于 sessionStorage 在关闭页面后即被清空,而 loca ...
- c:forEach 实现换行
Map<String,String> map = new TreeMap<String,String>(); map.put("key1", "v ...
- 给Amazon ec2 增加卷(Volume)并挂载到系统
给Amazon ec2 增加卷(Volume)并挂载到系统 前言 导师让师弟把实验的网站挂到亚马逊的EC2云服务器上.师弟对linux不太熟悉.就跑过来问我.于是花了一个小时搞定.问题主要是将EC2的 ...