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. linux根据该文件夹的读取权限和权限运行差异

    假设你linux下使用ls.细心的你会发现居然夹有权限运行.例如: drwxrwxr-x 11 cl cl 4096  9 25 14:22 ./ drwxr-xr-x 49 cl cl 4096 1 ...

  2. DSR on Openstack POC

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWFvbGlwaW5nNDU1bWxwNDU1/font/5a6L5L2T/fontsize/400/fil ...

  3. Cocos2d-x学习笔记(9)(CCTextFieldTTF使用输入框)

    1.CCTextFieldTTF创建和使用 CCTextFieldTTF::create(const char* placeholder,const char* fontName.float font ...

  4. 如何知道 win10 的激活到期时间和期限等

    在“运行”里输入cmd,出来dos对话框后,输入下面的东西后,按Enterslmgr.vbs -dli (显示:操作系统版本.部分产品密钥.许可证状态)slmgr.vbs -dlv (显示:最为详尽的 ...

  5. Webx框架:Valve详细解释

    Valve请求,用于控制过程的操作.它采用责任设计模式链(类别似至struts拦截器).valve阀装置,阀控制水流量(网络请求)趋势. 他们阀门定义. public class MyValve im ...

  6. hadoop得知;block数据块;mapreduce实现样例;UnsupportedClassVersionError变态;该项目的源代码相关联

    对于开源的东西.特别是刚出来不久.我认为最好的学习方法是能够看到源代码,doc,样品测试 为了方便查看源代码,导入与项目相关的源代码 watermark/2/text/aHR0cDovL2Jsb2cu ...

  7. Ini文件帮助类

    .ini文件是什么 .ini 文件是Initialization File的缩写,就是初始化文件.在Windows系统中,其是配置文件所采用的存储格式(主要是system.ini,win.ini,sy ...

  8. java main方法背后的故事?(转)

    jvm java 看似一种语言,实则一个巨大的体系的王国,开发这么多年了,还是没有搞懂,我以为我懂了,可是过了一段时间又忘了,所以说还是没懂 1.main方法说起 编译完我们的java文件后,需要有个 ...

  9. freemarker定义自己的标签错误(八)

    1.错误叙述性说明 freemarker.core.ParseException: Token manager error: freemarker.core.TokenMgrError: Unknow ...

  10. Cts框架解析(7)-任务运行的调度室

    TestInvocation /** * {@inheritDoc} */ @Override public void invoke(ITestDevice device, IConfiguratio ...