| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1245 人关注过本帖
标题:来做题啊!
取消只看楼主 加入收藏
虾米1号
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-2-29
收藏
 问题点数:0 回复次数:0 
来做题啊!
A Pilot in Danger!
Input file: Pilot.in
The World War II was going on in 1941. Germany, Italy and Hungary had occupied Yugoslavia for months. Led by Tito, though having losing thousands of lives and still being under the threat of Fascist, Yugoslav were fighting against the enemy toughly until the enemy escaped from their motherland. On the east, although on August 23rd, 1939 Germany and Soviet Union signed a treaty that they wouldn’t invade each other, Hitler attacked Soviet Union without declare on June 22nd, 1941. The war came into more and more impetuous. On October 2nd, Germany began to attack Moscow, trying to occupy it in ten days. However, Moscow still alive after two months, as sacrificing thousands of people! Then, after Moscow Defense and Stalingrad Defense, Soviet Union counterattacked Germany.
One day, the oil of a Soviet bomber on task run down, and the pilot had to bail out in the enemy region. He was in danger! He became calm quickly, and he must know whether he’s in enemy’s barrack, for he was not afraid of any enemy out of their barrack. If unfortunately he’s, he must get the secret number, which allowed anyone pass the watch without trouble.
The barrack was an area bounded by a fence on some flat field. In the plane projection the fence has a form of a closed polygonal line (without self-intersections), which was specified by Cartesian coordinates (xi, yi) of its n vertices. The pilot stood on the field at the point with coordinates (0, 0). The pilot may be located either outside or inside the fence, but not on its sides.
How to get the secret number of the barrack? There are two different primes p, q, p≠q, in the barrack, as everybody could get it with ease. The secret number indicated that how many positive integers that can not be in the form of px+qy while x, y are integers and x, y≥0.
For example, given p=3 and q=5, there are four positive integers, 1, 2, 4, 7, which can not be in the form mentioned above. So, the secret number was 4.
Your task: Decide whether the pilot was in the barrack. If he was, get the secret number.
Input
The input file consists with several tests. For every test, first line contains a single integer n, fitting 3≤n≤16, and while n=0 means the end of the input. n is the number of the vertices of the fence. Then n files follow, every line contains two real numbers xi and yi, separated by space(s). After that, there are two different primes p, q, 2≤p, q≤1000, in the next line, which help you to get the secret number as above.
The vertices may appear clockwise or counterclockwise.
Output
For every test, first output the number of the pilot. Next line tell us whether the pilot was in danger (if he’s in the enemy’s barrack) or not. If he was, tell us the secret number in the next line.
Write an empty line after every test.
Sample Input
4
-1.0 -1.0
2.0 -1.0
2.0 2.0
-1.0 2.0
3 5
5
-2.5 -2.5
10.5 -2.5
10.5 -1.5
-1.5 -1.5
-2.5 20.5
2 7
0
Sample Output for Sample Input
Pilot 1
The pilot is in danger!
The secret number is 4.

Pilot 2
The pilot is safe.
搜索更多相关主题的帖子: thousands fighting although against without 
2008-02-29 19:10
快速回复:来做题啊!
数据加载中...
 
   



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

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