博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Diophantus of Alexandria(唯一分解定理)
阅读量:5011 次
发布时间:2019-06-12

本文共 2156 字,大约阅读时间需要 7 分钟。

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

241260

Sample Output

Scenario #1:3Scenario #2:113 代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
const int maxn=1e5+5;typedef long long ll;using namespace std;int prime[1000005];bool vis[1000005];int cnt =0;void erla() { memset(vis,false,sizeof(vis)); memset(prime,0,sizeof(prime)); for(int t=2; t<=1000003; t++) { if(!vis[t]) { prime[cnt++]=t; } for(int j=0; j
<=1000003; j++) { vis[t*prime[j]]=true; if(t%prime[j]==0) { break; } } }}int main(){ int T; erla(); cin>>T; int ca=1; while(T--) { int n; scanf("%d",&n); ll ans=1; for(int t=0;t

 

转载于:https://www.cnblogs.com/Staceyacm/p/11241292.html

你可能感兴趣的文章
调用Android系统“应用程序信息(Application Info)”界面
查看>>
ios中用drawRect方法绘图的时候设置颜色
查看>>
数据库中的外键和主键理解
查看>>
个人博客03
查看>>
Expression<Func<T,TResult>>和Func<T,TResult>
查看>>
文件缓存
查看>>
关于C语言中return的一些总结
查看>>
Codeforces Round #278 (Div. 2)
查看>>
51. N-Queens
查看>>
Linux 命令 - 文件搜索命令 locate
查看>>
[Grunt] grunt.template
查看>>
Ubuntu最小化桌面快捷键Super+D不生效解决
查看>>
Cookie&Session会话跟踪技术
查看>>
UNIX环境高级编程 第17章 高级进程间通信
查看>>
ES的Zen发现机制
查看>>
【hibernate】1、Hibernate的一个注解 @Transient
查看>>
HihoCoder 1877 - Approximate Matching
查看>>
Elastic Search 语法总结
查看>>
py自动化之环境配置
查看>>
Winodws SNMP服务安装和配置(Windows 2003 & 2008 R2)
查看>>