F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

ZaakDov is doing his math problem!

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 794    Accepted Submission(s): 202


Problem Description
Given an odd prime p.
You are to tell whether p can be written into form a^2+b^2 (0<a<=b),
and if p can be done, you are to determine a pair of a,b.
 

Input
There will be up to 2*10^5 test cases.
An odd prime p (3<=p<2*10^9) in each line.
End with EOF.
 

Output
For each number p,
if p can be written into form a^2+b^2 (0<=b),
output one line that contains "Legal a b",
and if not just output one line that contains "Illegal".
For a certain p that can be written into the form described above, any pair of a,b (0<=b) will do.
 

Sample Input
3 5 7 11 13 17 19 23 29
 

Sample Output
Illegal Legal 1 2 Illegal Illegal Legal 2 3 Legal 1 4 Illegal Illegal Legal 2 5
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-12 03:03:21, Gzip enabled