| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 632 人关注过本帖
标题:正在进行的ICPC题目(NO.D)
只看楼主 加入收藏
蓝色神话
Rank: 2
等 级:论坛游民
威 望:1
帖 子:404
专家分:24
注 册:2006-5-11
收藏
 问题点数:0 回复次数:1 
正在进行的ICPC题目(NO.D)

Genius
Time Limit:1.5S Memory Limit:65536K


Description
For each natural number N (N>0),
Primary school students know if there exists an integer a, such that a2=N, then N is a perfect square.
Junior school students know if sqrt(N) is an irrational number, N is not a perfect square(square-free). High school students know that N is a perfect square if and only if there exists two positive integers X and Y, such that N=X2/Y2.
College students know that N is square-free if and only if there exists two positive integers X and Y, such that N=(X2-1)/Y2.
As a mathematics and programming genius, you know far more than them. Not only are the above four simple propositions a piece of cake to you, but also you can tell them how much X and Y are for each square-free N, such that (X2-1)/Y2=N.
You need to write a program which inputs an integer N and outputs X and Y.
Such X and Y may be multiple. Please output the minimum X and Y.

Input
The input consists of several test cases. Each test case is in a separate line, and consists of a single integer in the range 1 ... 10^8.
The last case is followed by a line containing an integer zero.


Output
For each test case, display a line that contains X and Y. if either X or Y is greater than or equal to 10^1000, output 'No solution!'.

Sample Input


3
57
81
0


Sample Output


Case 1:
2 1
Case 2:
151 20
Case 3:
No solution

谁能解决?

搜索更多相关主题的帖子: ICPC square students know 
2006-10-07 14:14
cwande
Rank: 2
等 级:新手上路
威 望:3
帖 子:333
专家分:0
注 册:2006-8-18
收藏
得分:0 

楼主竟然刷得进去................
今天的网络赛Tshinghua要被人B4了,太不重视了


汗,都懒得写代码了.......... cheat了一个威望,哈.....
2006-10-07 21:32
快速回复:正在进行的ICPC题目(NO.D)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038042 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved