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. 20160723数据结构节alexandrali

    大坑最后再填. 20160803:心情好回来填啦(5/7) 做的题目是: poj2970 我们先每个人都不给钱qwq 然后我们发现有一位的工作时间超过了d 那么我们就从以前安排过工作的人里,a最大的, ...

  2. C++代码反汇编后的堆栈寄存器EBP和ESP

    最近在分析一个进程崩溃的严重问题,其中有些过程分析需要对ebp, esp 有清晰的理解,对于ebp 和esp 相信大家都很熟悉了,但是为了使本文自成体系,我还是解释一下. ebp--栈底指针 esp- ...

  3. 转载一个不错的Scrapy学习博客笔记

    背景: 最近在学习网络爬虫Scrapy,官网是 http://scrapy.org 官方描述:Scrapy is a fast high-level screen scraping and web c ...

  4. POJ 1795

    DNA Laboratory Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 1425   Accepted: 280 Des ...

  5. who is in front of me 解题报告

    题目描述:N(1<=N<=50005)个学生站成一个纵队,每个人只能看到前面身高比他高(严格大于)的人 求所有人中能看到的最大人数 分析:对于某个人A,设前面第一个身高比他高的人是B.如果 ...

  6. 实战案例--Grunt构建Web程序

    GruntJS构建Web程序.使用Gruntjs来搭建一个前端项目,然后使用grunt合并,压缩JS文件,熟练了node.js安装和grunt.js安装后,接下来来实战一个案例,案例是根据snandy ...

  7. POJ3250Bad Hair Day

    http://poj.org/problem?id=3250 题意 :  n个牛排成一列向右看,牛 i 能看到牛 j 的头顶,当且仅当牛 j 在牛 i 的右边并且牛 i 与牛 j 之间的所有牛均比牛 ...

  8. JAVASCRIPT中的作用域和原型链,应该算是难点了,要好好多学学,练练

    今天初六,要上班啦... JAVASCRIPT,看来是丢不了了.. http://www.dengdeng90.com/wordpress/?p=241 http://www.cnblogs.com/ ...

  9. BCB常用文件与字符串函数

    VCL库函数简介 一.BORLAND C++ BUILDER VCL的内存管理函数 1. AllocMem 在队中分配指定字节的内存块,并将分配的每一个字节初始化为 0.函数原型如下: void * ...

  10. 256. Paint House

    题目: There are a row of n houses, each house can be painted with one of the three colors: red, blue o ...