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. uitableView 选择跳过后, 跳回 颜色变化 问题

    今天遇到这个问题  谁也因此没有满足这方面的需求 今天会见 网上办理登机手续 未找到 好 我只能说自己的问题 但 幸好,kai哥 就攻克了 ! 就是在- (void)tableView:(UITabl ...

  2. MyReport报表引擎2.0.0.0新功能

    Web报表引擎:Web上的良好的打印解决方式,WinForm的打印预览体现,报表自己主动化,支持直接打印,页小计,统计,转成金额大写,一维码显示等功能,满足中国式报表的常见功能需求.Web报表编辑器: ...

  3. Chapter 1 Securing Your Server and Network(4):使用虚拟服务帐号

    原文:Chapter 1 Securing Your Server and Network(4):使用虚拟服务帐号 原文出处:http://blog.csdn.net/dba_huangzj/arti ...

  4. Android应用程序绑定服务(bindService)的过程源码分析

    Android应用程序组件Service与Activity一样,既能够在新的进程中启动,也能够在应用程序进程内部启动:前面我们已经分析了在新的进程中启动Service的过程,本文将要介绍在应用程序内部 ...

  5. Hadoop处理HDF文件

    1.前言 HDF文件是遥感应用中一种常见的数据格式,因为其高度结构化的特点,笔者曾被怎样使用Hadoop处理HDF文件这个问题困扰过相当长的一段时间.于是Google各种解决方式,但都没有找到一种理想 ...

  6. BigPipe设计原理

    高性能页面加载技术--BigPipe设计原理及Java简单实现 1.技术背景 动态web网站的历史可以追溯到万维网初期,相比于静态网站,动态网站提供了强大的可交互功能.经过几十年的发展,动态网站在互动 ...

  7. 第十二章——SQLServer统计信息(4)——在过滤索引上的统计信息

    原文:第十二章--SQLServer统计信息(4)--在过滤索引上的统计信息 前言: 从2008开始,引入了一个增强非聚集索引的新功能--过滤索引(filter index),可以使用带有where条 ...

  8. 如何嗅闻交换网络和ARP骗子-ARP解释的原则

    在嗅探以太网(一般指嗅探器可以对流经的网络数据包窃听)(sniff)不为网络安全是好事,虽然网络管理员能够跟踪数据包,发现 互联网问题,但前提是,如果破坏者使用.在整个网络带来了严重的安全威胁. 至于 ...

  9. super.getClass()与this.getClass()

    原文地址:http://leihuang.org/2014/11/14/getClass-method/ 首先看一段代码: import java.util.Date; public class Te ...

  10. COCOFrame

    COCOFrame它是一个轻量级的开发框架,综合Android APP开发过程中经常使用的工具,方法,特效.当中F类採用的AndroidQuery实现,做了进一步的封装及部分优化. 1. Jar包大小 ...