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+m)
// 1/y = m/(n*n+n*m) 所以满足 n*n|m 的m都是可以的
// 问题转化成求n*n 的约数个数 因数分解 然后用求约数个数公式
// 最后答案记得 除 2 因为重复算了
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxm 100010
// #define maxn 47010
#define LL __int64
int prim[],p;
void getPrime(){
int maxn=sqrt(1000000001.0);
int i,j;
for(i=;i<=maxn;i+=)
prim[i]=;
for(i=;i*i<=maxn;i+=)
if(!prim[i])
for(j=i*i;j<=maxn;j+=i)
prim[j]=;
for(i=;i<=maxn;i++)
if(!prim[i]) prim[p++]=i;
}
int main()
{
getPrime();
int n,T;
LL ans;
int i,ct,Case=;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
i=;
ans=;
while(i<p){
if(n%prim[i]==){
ct=;
while(n%prim[i]==){
ct++;
n=n/prim[i];
}
ans=ans*(*ct+);
}
if(n==) break;
i++;
}
if(n!=) ans=ans*;
printf("Scenario #%d:\n",Case++);
printf("%I64d\n\n",(ans+)/);
}
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 (数论)
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- 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 ...
随机推荐
- [CF]codeforces round 369(div2)
*明早起来再贴代码 A [题意] 给定n*5的方格 将横向的相邻两个变成+输出 [题解] ... B [题意] 一个n*n的正整数矩阵,有且仅有一个数为0 ,在这个位置填上一个数,使得每一列的和 每一 ...
- semantic
cgfx 里会有这个 float4X4 View : View; :后面这个 view 是一种 叫做user defined semantic provide the correct data to ...
- [设计模式] 7 适配器模式 adapter
在 Adapter 模式的结构图中可以看到,类模式的 Adapter 采用继承的方式复用 Adaptee的接口,而在对象模式的 Adapter 中我们则采用组合的方式实现 Adaptee 的复用 类模 ...
- winform DataGridView控件开发经验
1.不让DataGridView控件自动生成列 设置AutoGenerateColumns 为false. dgTicket.AutoGenerateColumns = false; //将自动生成列 ...
- Browser detect
A useful but often overrated JavaScript function is the browser detect. Sometimes you want to give s ...
- HDU1251 统计难题 Trie树
题目很水,但毕竟是自己第一道的Trie,所以还是发一下吧.Trie的更多的应用慢慢学,AC自动机什么的也慢慢学.... #include<iostream> #include<cst ...
- ssh 公钥
以前做ssh key登录方式时都是用的root帐号,基本都是无往不利的,权限采用默认即可.今天实验中两台机器帐号都是nianzong,一个普通的帐号.按照如下步骤: A机器:ssh-keygen -t ...
- 解决在windows的eclipse上面运行WordCount程序出现的一系列问题详解
一.简介 要在Windows下的 Eclipse上调试Hadoop2代码,所以我们在windows下的Eclipse配置hadoop-eclipse-plugin- 2.6.0.jar插件,并在运行H ...
- PHP中的多态
多态的概念一般是强类型语言来谈的,因为强类型语言它必须要声明参数类型,比如一个手电筒对象的打开方法其参数申明了只能是蓝光,就不能传其他光.但可以用父类渲染的方式使其多态,比如声明一个光的父类,让其它颜 ...
- UML建模之活动图介绍(Activity Diagram)
一.活动图的组成元素 Activity Diagram Element 1.活动状态图(Activity) 2.动作状态(Actions) 3.动作状态约束(Action Constraints) 4 ...