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. 物理地址 = 段地址*10H + 偏移地址

    程序如何执行: CPU先找到程序在内存中的入口地址 -- 地址总线 (8086有20根地址总线,每一根可以某一时传0或1, 20位的二进制数字可以表示的不同的数字的个数是2^20=1048576 10 ...

  2. Unity3D脚本中文系列教程(十三)

    http://dong2008hong.blog.163.com/blog/static/469688272014032334486/ Unity3D脚本中文系列教程(十二) ◆ function G ...

  3. sql 判断两个时间段是否有交集

    本文转自CSDN 链接地址:http://blog.csdn.net/dasihg/article/details/8450195 时间段:starttime_1到endtime_1,starttim ...

  4. UIkit的confirm,好看点

    一,官方推荐的样码. <button type="button" class="uk-button" onclick="UIkit.modal. ...

  5. Android:打包apk

    右击项目->导出export next,完成相关信息填写将得到.apk文件,即可部署到手机上. 第一次: 然后打开目录就可以看到生成的apk,可以发布到各大市场上.

  6. photoshop:调整图层之色相/饱和度

    色相/饱和度:快速调色及调整图片色彩浓淡明暗 面板主要参数:色相.饱和度.明度 色相用来改变颜色:顺序按红-黄-绿-青-蓝-洋红 饱和度用来控制色彩浓淡 明度控制色彩明暗 勾选“着色”,图片会变成单色 ...

  7. wxpython ItemContainer

    ItemContainer 是 很多可以添加string item的部件的父类,封装很多有用的方法,可以用来获取部件的被选中item 的string 如wx.ListBox ,wx.CheckList ...

  8. 英文论文写作之讨论与结论Discussion and Conclusion

    Discussion and Conclusion After viewing these maps, what should immediately appear is the level of r ...

  9. (sql server)数据分页的实现

    谈谈自己了解的几种数据库分页的方法,下面來分享下,有什么好的方法可以指导一下哦.. 方法一:利用ROW_NUMBER()方法 利用ROW_NUMBER 产生序列后直接取出 /*如要查詢的表為Test ...

  10. proc_dir_entry

    struct proc_dir_entry {        unsigned int low_ino;        unsigned short namelen;        const cha ...