hdu 1299 Diophantus of Alexandria (数论)
Diophantus of Alexandria
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2269 Accepted Submission(s): 851
of Alexandria was an egypt mathematician living in Alexandria. He was
one of the first mathematicians to study equations where variables were
restricted to integral values. In honor of him, these equations are
commonly called diophantine equations. One of the most famous
diophantine equation is x^n + y^n = z^n. Fermat suggested that for n
> 2, there are no solutions with positive integral values for x, y
and z. A proof of this theorem (called Fermat's last theorem) was found
only recently by Andrew Wiles.
Consider the following diophantine equation:
1 / x + 1 / y = 1 / n where x, y, n ∈ N+ (1)
Diophantus
is interested in the following question: for a given n, how many
distinct solutions (i. e., solutions satisfying x ≤ y) does equation (1)
have? For example, for n = 4, there are exactly three distinct
solutions:
1 / 5 + 1 / 20 = 1 / 4
1 / 6 + 1 / 12 = 1 / 4
1 / 8 + 1 / 8 = 1 / 4
Clearly,
enumerating these solutions can become tedious for bigger values of n.
Can you help Diophantus compute the number of distinct solutions for big
values of n quickly?
first line contains the number of scenarios. Each scenario consists of
one line containing a single number n (1 ≤ n ≤ 10^9).
output for every scenario begins with a line containing "Scenario #i:",
where i is the number of the scenario starting at 1. Next, print a
single line with the number of distinct solutions of equation (1) for
the given value of n. Terminate each scenario with a blank line.
//140MS 200K 622 B G++
#include<stdio.h>
#include<math.h>
long long solve(int n)
{
long long ans=;
int i;
int m=(int)sqrt(n+0.5);
for(i=;i<=m;i++){
int ret=;
if(n%i==){
n/=i;
while(n%i==){
n/=i;ret++;
}
ans*=(*ret+);
}
if(n<i) break;
}
if(n>) ans*=;
return ans;
}
int main(void)
{
int n;
int cas=,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("Scenario #%d:\n%lld\n",cas++,solve(n)/+);
printf("\n");
}
return ;
}
hdu 1299 Diophantus of Alexandria (数论)的更多相关文章
- hdu 1299 Diophantus of Alexandria(数学题)
题目链接:hdu 1299 Diophantus of Alexandria 题意: 给你一个n,让你找1/x+1/y=1/n的方案数. 题解: 对于这种数学题,一般都变变形,找找规律,通过打表我们可 ...
- 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 1299 基础数论 分解
给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...
- 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 ...
- Diophantus of Alexandria
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...
随机推荐
- 解决java文件编码和windows7系统(中文版)默认编码冲突所导致的乱码情况
开篇从一个比较简单但是也比较蛋疼的问题开始吧. 背景介绍:我是新手小白,初学java. 问题介绍:在使用UTF-8编码格式写java文件时,编译出现问题. 原因分析:1.java文件的编码格式是UTF ...
- 如何为datagridview加上序号
最简单的方法是在Datagridview的事件RowPostPaint事件下面添加如下代码即可 private void dataGridView1_RowPostPaint(object sende ...
- Jmeter beanshell 生成手机号加密签名
首先自己写一个根据手机号生成加密字符串的函数,并且导出为Jar包,函数具体内容省略,网上有很多 将Jar包放到Jmeter lib\ext目录下面,然后在user.properties里面把路径加进去 ...
- Ubuntu Kylin 14.04-修改IP固定地址
前言:今天我们办公室的网络不稳定,隔一会时间就断掉,后来请负责网络的同事来处理了一下,说是路由器的有些配置起冲突了,所以他将IP地址做了一些修改,比如:原IP是192.168.0.110 ...
- jsp+tomcat+mysql+sevlet+javabean配置过程
在配置jsp开发环境的过程中会碰到不少问题,感谢网上的许多前辈的经验总结,作者cl41的JSP连接Mysql数据库攻略和作者Saulzy的MySQL学习笔记等文章对我来说简直是雪中送碳,为了帮助象我一 ...
- C# 基础排序与查找算法
排序算法: class Sort { static void swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; } #regio ...
- 第一天 :学习node.js
① node.js环境配置 我学过的语言最简单的一门 直接百度就可以配置 ② 每个入门 的程序都是从helloworld开始 代码如下 : var http=require('http'); http ...
- go语言环境搭建+sublime text3(windows环境下)
感觉有点坑,整了一下午~搞定 go语言环境搭建+sublime text3(windows环境下) 1.安装sublime text3 2.安装go语言程序包 3.测试go语言是否安装成功 键 ...
- ue4标签测试与总结(UPROPERTY)
学习UE4框架中的标签,本篇是总结成员变量标签UPROPERTY. 引擎版本:4.12.5 前期准备: 1.新建项目,C++空模板,新建C++类,继承AActor,名称MyActor. 使用TestA ...
- About Mysql 5.7 Installation
After version of mysql 5.7, mysql increase its security level. CMD run as adminstratot cd c:/mysql/b ...