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. 【锋利的JQuery-学习笔记】广告栏

    效果图: html: <div id="jnImageroll"> <a href="#nogo" id="JS_imgWrap&q ...

  2. 跨线程调用控件之MethodInvoker

    原文:http://www.cnblogs.com/cm8448940/archive/2008/07/10/1240045.html 使用到两个控件,一个按钮button1,一个标签label1. ...

  3. Web Server 和 HTTP 协议

    https://toutiao.io/posts/xm2fr/preview 一直在找实习,有点什么东西直接就在evernote里面记了,也没时间来更新到这里.找实习真是个蛋疼的事,一直找的是困难模式 ...

  4. First Lua function running in C

    这是我在C里面跑出来的第一个Lua 文件, 纪念一下. 1.Set up envirnonment: Mac下面 Lua的src (即include) 和lib(binary)是分开的, 所以需要分别 ...

  5. POJ2104 k-th number 划分树

    又是不带修改的区间第k大,这次用的是一个不同的方法,划分树,划分树感觉上是模拟了快速排序的过程,依照pivot不断地往下划分,然后每一层多存一个toleft[i]数组,就可以知道在这一层里从0到i里有 ...

  6. POJ1321棋盘问题

    http://poj.org/problem?id=1321 题意 : 我能说这是迄今为止见到的POJ上第二道中文题吗,既然是中文也很好理解,就不详述了 思路 : 典型的深搜DFS ; #includ ...

  7. hdu 1333 Smith Numbers

    刚开始没看清题意,要找的数一定要是素数 ;}

  8. Mac 如果一定要写个锁屏程序的话就这样

    package test; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import ...

  9. lintcode :implement queue by two stacks 用栈实现队列

    题目 用栈实现队列 正如标题所述,你需要使用两个栈来实现队列的一些操作. 队列应支持push(element),pop() 和 top(),其中pop是弹出队列中的第一个(最前面的)元素. pop和t ...

  10. LAMP环境 源码包安装

    linux的学习很早就开始了,大学的时候的时候有有学过unix,后来每年都有去看看linux,因为在小城市的缘故,很少会实际工作中用到,基本都是智慧云之类的,同事也说,你学起来也用不上,IT生态不好, ...