当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3361:Gaussian Prime Factors

题目描述

Let a, b, c, d be integers. The complex number a+bj, where j2 = -1, is a factor of c+dj, if there exist integers e and f such that

c + dj = (a + bj)(e + fj).

A complex number a + bj where a and b are integers is a Gaussian prime if the factors are 1, -1, -a - bj and a + bj only.

The following are Gaussian primes: 1 + j, 1 - j, 1 + 2j, 1 - 2j, 3 and 7.

The Gaussian prime factors of 5 are:

1 + 2j and 1 - 2j, or
2 + j and 2 - j, or
-1 - 2j and -1 + 2j, or
-2 - j and -2 + j.

Write a program that finds all the Gaussian prime factors of a positive integer.

输入解释

One line of input per case. The line represents a positive integer n.

输出解释
One line of output per test case. The line represents the Gaussian prime factors of n. If a + bj is a Gaussian prime factor of n, then a > 0, |b| ≥ a, if b ≠ 0. If b = 0, the output must be a.
输入样例
2
5
6
700
输出样例
Case #1: 1+j, 1-j 
Case #2: 1+2j, 1-2j 
Case #3: 1+j, 1-j, 3 
Case #4: 1+j, 1-j, 1+2j, 1-2j, 7
提示

Output the Gaussian prime factors in ascending order of a. If there are more than one factors with the same a, output them in ascending order of b by absolute value. If two conjugate factors coexist, the one with a positive imaginary part precedes that with a negative imaginary part.


该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Manila 2006

源链接: POJ-3361

最后修改于 2020-10-29T06:59:38+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536