Description

Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to integral values. In honor of him, these equations are commonly called diophantine equations. One of the most famous diophantine equation is x^n + y^n = z^n. Fermat suggested that for n > 2, there are no solutions with positive integral values for x, y and z. A proof of this theorem (called Fermat's last theorem) was found only recently by Andrew Wiles.

Consider the following diophantine equation:

1 / x + 1 / y = 1 / n where x, y, n ∈ N+ (1)

Diophantus is interested in the following question: for a given n, how many distinct solutions (i. e., solutions satisfying x ≤ y) does equation (1) have? For example, for n = 4, there are exactly three distinct solutions:

1 / 5 + 1 / 20 = 1 / 4 
1 / 6 + 1 / 12 = 1 / 4 
1 / 8 + 1 / 8 = 1 / 4

Clearly, enumerating these solutions can become tedious for bigger values of n. Can you help Diophantus compute the number of distinct solutions for big values of n quickly? 

 

Input

The first line contains the number of scenarios. Each scenario consists of one line containing a single number n (1 ≤ n ≤ 10^9). 
 

Output

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Next, print a single line with the number of distinct solutions of equation (1) for the given value of n. Terminate each scenario with a blank line. 
 

Sample Input

2
4
1260
 

Sample Output

Scenario #1:
3

Scenario #2:
113

 
 #include <string.h>
#include <stdio.h>
#define M 40000
int prime[];
void dabiao()//筛选素数
{
int i,j;
memset(prime,,sizeof(prime));
for(i=; i<=M; i++)
{
if(prime[i]==)
{
for(j=i+i; j<=M; j+=i)
{
prime[j]=;
}
}
}
}
int fenjie(int n)//素数因子分解
{
int i,k,sum=;
for(i=; i<=M; i++)
{
if(n==)
break;
if(prime[i]==)
{
k=;
while(n%i==)
{
k++;
n=n/i;
}
sum=sum*(*k+);
}
}
if(n>)
sum=sum*;
return sum;
}
int main()
{ dabiao();
int n,i,j,t;
scanf("%d",&t);
int p=;
while(t--)
{
scanf("%d",&n);
printf("Scenario #%d:\n",p);
printf("%d\n\n",(fenjie(n)+)/);
p++;
}
return ;
}

hdu Diophantus of Alexandria(素数的筛选+分解)的更多相关文章

  1. HDOJ/HDU 2710 Max Factor(素数快速筛选~)

    Problem Description To improve the organization of his farm, Farmer John labels each of his N (1 < ...

  2. hdu 1299 Diophantus of Alexandria (数论)

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

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

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

  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. hdoj 1299 Diophantus of Alexandria

    hdoj 1299 Diophantus of Alexandria 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1299 题意:求 1/x + 1/y ...

  6. HDU 2098 分拆素数和(素数)

    HDU 2098 分拆素数和(素数) http://acm.hdu.edu.cn/showproblem.php?pid=2098 题意: 给你一个偶数,问你这个偶数有多少种方式能由两个不同的素数构成 ...

  7. HDU 1299Diophantus of Alexandria

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

  8. Diophantus of Alexandria[HDU1299]

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

  9. HDU 2098 分拆素数和

    HDU 2098 分拆素数和 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768K (Java/Others) [题目描述 ...

随机推荐

  1. Android毛玻璃处理代码(Blur)

    以下为将bitmap图像处理为毛玻璃效果的图像的工具类: public class FastBlurUtil { public static Bitmap doBlur(Bitmap sentBitm ...

  2. 【Web探索之旅】第四部分:Web程序员

    内容简介 1.第四部分第一课:什么是Web程序员? 2.第四部分第二课:如何成为Web程序员? 3.第四部分第三课:成为优秀Web程序员的秘诀 第四部分:Web程序员(完结篇) 大家好.终于来到了[W ...

  3. SQL学习之--触发器

    USE [learn2] GO /****** Object: Trigger [dbo].[trigger_AdClass] Script Date: 09/30/2014 09:01:03 *** ...

  4. sql pivot、unpivot和partition by用法

    原文:sql pivot.unpivot和partition by用法 演示脚本 from sys.sysobjects where name = 'Student' AND type = 'U') ...

  5. 最大公约数(Greatest Common Divisor)

    两个数的最大公约数.一个典型的解决方案是欧几里德,叫欧几里德算法. 原理:(m,n)代表m和nGCD,和m>n.然后,(m,n)=(n,m%n)=.....直到余数为0. 码如下面: publi ...

  6. crm创建基于fetch自己的自定义报告

    在解决方案资源管理器,右键点击"报表"目录.然后点击"增加了新的报告". 打开"报表向导". 在"欢迎来到报表向导"前, ...

  7. Android - 支持不同的设备 - 支持不同的语言

    把app的字符串放到另外一个文件中是一个好习惯.Android用android工程中的资源文件夹让这件事变的很简单. 如果使用Android SDK Tools创建工程,这个工具会在工程的根目录下创建 ...

  8. 2C 产品的本质是人性,2B 产品的背后是业务(转)

    本文作者李源是 BLUES 原来做 YY 语音客户端产品时候的同事,原来针对 YY 语音的游戏用户做 2C 的 PC 客户端产品和 APP,后来到某品牌手机做 2B 的后台系统.以下文章,是作者经历了 ...

  9. 在Ceph创建虚拟机的过程改进分析

    作为个人学习笔记分享.有不论什么问题欢迎交流! 近期在Gerrit中看到一个change:https://review.openstack.org/#/c/94295/ , 它主要是对当前在Ceph中 ...

  10. 在java代码中获取JVM参数(转)

    近日关注性能调优,关注JMX,发现java.lang.management.*之强大.同时查阅了资料,整合一版关于JVM参数获取的note,仅供参考: MemoryMXBean memorymbean ...