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. Source Insight 3.X 插件支持utf8,完美解决中国乱码,连接到美丽的轮廓

    上次SI多标签插件之后,由于公司内部编码改为utf8编码,因此特意做了这个Source Insight 3.X utf8插件. 下载地址:http://pan.baidu.com/s/1mgyZous ...

  2. 《图书管理系统——java》

    /* (程序头部凝视開始) * 程序的版权和版本号声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名:    < ...

  3. c# socket udp广播

    一.广播消息 由于Tcp是有连接的,所以不能用来发送广播消息.发送广播消息,必须用到Udp,Udp可以不用建立连接而发送消息.广播消息的目的IP地址是一种特殊IP地址,称为广播地址.广播地址由IP地址 ...

  4. 交换A与B值的四种方法

    在网上看到了这样一道面试题,"int A=5,int B=2,怎样交换A与B的值",或许这是一道简单到不能再简单的题,但能作为一道面试题,肯定有其独特之处 大多数人会通过定义第三个 ...

  5. 信息二战炸弹:中国到美国咨询公司Say no

    疯抢/文 在禁止Windows8操作系统參与政府採购,以及在中国销售的全部外国IT产品和服务都须通过新的安全审查之后,英国<金融时报>今天报料中国已禁止国企使用美国咨询公司服务. 这则消息 ...

  6. 【java基础】==与equals()方法比较

    1.八种基本类型 只有"=="方法进行判断是否相等,比较的是基本数据类型的值,没有equals()方法 2.Java类库中的类 "=="比较的是对象的句柄,即内 ...

  7. 第三篇——第二部分——第四文 配置SQL Server镜像——非域环境

    原文:第三篇--第二部分--第四文 配置SQL Server镜像--非域环境 本文为非域环境搭建镜像演示,对于域环境搭建,可参照上文:http://blog.csdn.net/dba_huangzj/ ...

  8. Cocos2d-x 3.0final 终结者系列教程04-引擎架构分析

    从前,有一个跟我来Android学生,总是问我: 沉老师,为什么Android的形式被称为Activity,为什么要onCreate方法写setContentView(R.layout.main)? ...

  9. MFC 盾webBrowser打开弹出的页面

    void CansDlg::NewWindow3Explorer1(LPDISPATCH* ppDisp, BOOL* Cancel, unsigned long dwFlags, LPCTSTR b ...

  10. linux下getsockopt和setsockopt具体解释及測试

    linux下getsockopt和setsockopt具体解释及測试 NAME 名字 getsockopt, setsockopt - get and set options on sockets 获 ...