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的更多相关文章

  1. hdu 1299 Diophantus of Alexandria(数学题)

    题目链接:hdu 1299 Diophantus of Alexandria 题意: 给你一个n,让你找1/x+1/y=1/n的方案数. 题解: 对于这种数学题,一般都变变形,找找规律,通过打表我们可 ...

  2. hdu 1299 Diophantus of Alexandria (数论)

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

  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. 2013 Asia Hangzhou Regional Contest

    Lights Against Dudely http://acm.hdu.edu.cn/showproblem.php?pid=4770 15个位置,所以可以暴力枚举那些放,对于放的再暴力枚举哪个转, ...

  2. ios开发小技巧之摇一摇截屏

    1. 监控摇一摇动作 1> 让当前视图控制器成为第一响应者 // 必须先让当前视图控制器成为第一响应者才能响应动作时间 [self becomeFirstResponder]; 2> 实现 ...

  3. synergy--共享你的键鼠

    synergy用来分享一套键鼠,作用于多台主机.可作用于linux.Windows和mac平台.工作方式是:将一台主机作为服务器端,然后服务器端将会分享自己的键鼠,另一台主机作为客户端连接服务端就可以 ...

  4. Chp18: Hard

    18.1 Write a function that adds two numbers. You should not use + or any arithmetic operators. Solut ...

  5. java基础知识回顾之java Thread类学习(八)--java多线程通信等待唤醒机制经典应用(生产者消费者)

     *java多线程--等待唤醒机制:经典的体现"生产者和消费者模型 *对于此模型,应该明确以下几点: *1.生产者仅仅在仓库未满的时候生产,仓库满了则停止生产. *2.消费者仅仅在有产品的时 ...

  6. java基础知识回顾之javaIO类--RandomAccessFile类

    java.io 类 RandomAccessFile java.lang.Object java.io.RandomAccessFile1.该类不是IO流中的子类.2.该类既能读又能写.3.该对象内部 ...

  7. 近期概况&总结

    下午考完英语的学考就要放假啦,是衡中的假期啊QAQ 所以灰常的激动,一点也不想写题(我不会告诉你其实假期只有一个晚上.. 自从CTSC&APIO回来之后就一直在机房颓颓颓,跟着zcg学了很多新 ...

  8. java io流缓冲理解

    bufferedinputstream和bufferedoutputstream:这两个类是在inputstream和outputstream的基础上增加了一个buffer的缓冲区,从而使数据不直接写 ...

  9. 创业草堂之六:CEO的财务自修课

    创业团队中一个最普遍的缺陷,是团队--尤其是团队的核心人物CEO,缺乏基本的财务知识和技能.一个不懂财务知识的CEO,即使业务能力再强,在投资人的眼里,他/她依然是一个笨拙的CEO.粗糙的CEO.鲁莽 ...

  10. Arc Engiene读取文档的属性

    设计界面 创建类 代码如下 using System; using System.Collections.Generic; using System.Linq; using System.Text; ...