Bank Numbers
Time limit1sMemory limit128 MB
Determine whether a given Gaussian-integer-like pair (m,n) is a Gaussian prime by checking divisors of m^2+n^2.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Implementation
- Solved
- No attempts yet
Problem
A bank number is an ordered pair of integers . For example, , , and are bank numbers.
Multiplication of bank numbers is defined by . For example, .
If some bank number satisfies , then is called a divisor of the bank number .
For any bank number , each of , , , , , , , is a divisor of . If , these eight bank numbers are all distinct, so every bank number with has at least eight divisors.
A bank number with is called prime if it has exactly eight divisors.
Given a bank number, write a program that decides whether it is prime.
Input
The first line contains the number of test cases. Each test case is a single line containing and of a bank number , separated by a space. ()
Output
For each test case, print P on its own line if the given bank number is prime, and C otherwise.
Hint
When , if is a common divisor of and , then is a divisor of , and the converse also holds.
Moreover, if , then .