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 xn + yn = zn. Fermat suggested that for n > 2, there are no solutions with positive integral values for xy 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)

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:

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 nquickly?

Input

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

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<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std; int prime[];
bool vis[];
int cnt =;
void erla() { memset(vis,false,sizeof(vis));
memset(prime,,sizeof(prime));
for(int t=; t<=; t++) {
if(!vis[t]) {
prime[cnt++]=t;
}
for(int j=; j<cnt&&t*prime[j]<=; j++) {
vis[t*prime[j]]=true;
if(t%prime[j]==) {
break;
}
}
}
} int main()
{
int T;
erla();
cin>>T;
int ca=;
while(T--)
{
int n;
scanf("%d",&n);
ll ans=;
for(int t=;t<cnt;t++)
{
ll s1=;
while(n%prime[t]==)
{
n/=prime[t];
s1++;
}
ans=ans*(*s1+);
if(n==)
{
break;
}
}
if(n!=)
ans*=;
ans=(ans+)/;
printf("Scenario #%d:\n",ca++);
printf("%lld\n\n",ans);
}
return ;
}

Diophantus of Alexandria(唯一分解定理)的更多相关文章

  1. NOIP2009Hankson 的趣味题[唯一分解定理|暴力]

    题目描述 Hanks 博士是 BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫 Hankson.现 在,刚刚放学回家的 Hankson 正在思考一个有趣的问题. 今天在课堂上,老师讲 ...

  2. UVA - 10375 Choose and divide[唯一分解定理]

    UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  3. uva10375 Choose and Divide(唯一分解定理)

    uva10375 Choose and Divide(唯一分解定理) 题意: 已知C(m,n)=m! / (n!*(m-n!)),输入整数p,q,r,s(p>=q,r>=s,p,q,r,s ...

  4. hdu 1299 Diophantus of Alexandria (数论)

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

  5. 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)

    http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. ...

  6. UVA 10375 Choose and divide【唯一分解定理】

    题意:求C(p,q)/C(r,s),4个数均小于10000,答案不大于10^8 思路:根据答案的范围猜测,不需要使用高精度.根据唯一分解定理,每一个数都可以分解成若干素数相乘.先求出10000以内的所 ...

  7. 唯一分解定理 poj 1365

    一行代表一个数 x 给你底数和指数 求x-1的唯一分解定理的底数和指数 从大到小输出 #include<stdio.h> #include<string.h> #include ...

  8. Diophantus of Alexandria[HDU1299]

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

  9. UVA294DIvisors(唯一分解定理+约数个数)

    题目链接 题意:输入两个整数L,U(L <= U <= 1000000000, u - l <= 10000),统计区间[L,U]的整数中哪一个的正约数最多,多个输出最小的那个 本来 ...

随机推荐

  1. SpringBoot+Mybatis关于开启驼峰映射的设置

    mybatis自定义的SQL语句中,如select语句,如果数据库表的字段为驼峰命名,即如img_address这样的形式,那么select语句执行的结果会变成null. 解决办法是在配置文件中加上开 ...

  2. CSS品控与流程

    精通CSS意味着不仅能写出可用的标记和样式,还能让代码好阅读.方便移植.易维护. 1.外部代码质量:调试CSS 外部代理质量就是用户能体验到的最终结果.主要体现在几个方面. 正确性.CSS属性名都写对 ...

  3. 一个试图了解JVM内存模型的两年经验的初级程序员,透彻!

    所有的编程语言中都有内存模型这个概念,区别于微架构的内存模型,高级语言的内存模型包括了编译器和微架构两部分.我试图了解了Java.C#和Go语言的内存模型,发现内容基本大同小异,只是这些语言在具体实现 ...

  4. idea中GitPush失败问题

    首先是你的项目中有和和历史不符的东西 Push rejected: Push to *****/***** was rejected 推拒绝:推送到起源/主人被拒绝 直接是解决办法,直接打开你要上传代 ...

  5. 将vscode打造成强大的C/C++ IDE

    一.安装 你可以直接从微软官网下载,如果你想要一个纯净的vscode(微软官方的有一项商标.一个插件库.一个 C# 调试器以及遥测),可以手动编译https://github.com/microsof ...

  6. html定时跳转页面

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. C#设计模式之4-原型模式

    原型模式(Prototype Pattern) 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/395 访问. 原型模式属 ...

  8. 四博智慧物联系统入门示例-1.增加一个DHT11温湿度传感器

    1.准备工作 DOIT农业控制开发板或者esp32模组,并下载 四博智慧物联系统快速入门-2.准备工作 章节中的固件 DHT11连接在端口01 使用快速入门注册的管理账号和用户 2.配置网络 3.绑定 ...

  9. loading动态效果

    html <div class="loadingcontainer" :style="{display:disp}"> <div class= ...

  10. 漏洞重温之XSS(下)

    XSS总结 XSS的可利用方式 1.在登录后才可以访问的页面插入xss代码,诱惑用户访问,便可直接偷取用户cookie,达到窃取用户身份信息的目的. 2.修改昵称,或个人身份信息.如果别的用户在登录状 ...