2011-10-27 12:43:57Morris

第九次ITSA線上程式設計大賽競賽題目

注意事項
一、本比賽系統採用PC2,所使用的 I/O 是標準輸出輸入裝置,所以可以使用C語言的scanf ( )
printf ( ) ,或是C++語言上的 cin、cout來 讀入及輸出資料,比較要注意的是:本系統並不是用人工方式來keyin資料,所以不必在意使用者界面的問題,也就是說不用印出像是 "Please enter a number" 或 "The answer is"〃〃〃之類的文字;此外,有些題目是以讀到 EOF 為 input 結束,有些是讀入0結束等等的,必需善用I/O函式〃
二、比賽用的編譯器版本:gcc 3.4.4 、 g++ 3.4.4 、 jdk 1.6.0_23 、 Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1 、 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01。若出現Compilation Error,可能是某些函式不支援。
三、PC2系統判定錯誤可能原因:
正確答案 錯誤答案
四、PC2系統判定結果說明:
結果
說明
Yes
解題正確
No - Compilation Error
錯誤:編譯錯誤
No - Run-time Error
錯誤:程序運行錯誤
No - Time-limit Exceeded
錯誤:運行超時 (每道題都有運行時間限制)
No - Wrong Answer
錯誤:運行結果與標準答案不一致
No - Excessive Output
錯誤:程序運行佔用內存空間超出要求
No - Output Format Error
錯誤:輸出格式錯誤
No - Other - Contact Staff
未知錯誤
多空白
結尾沒有
換行字元
多換行字元
假設題目
要求結尾有
換行字元
Problem 1. Disjoint triangles
(Time Limit: 20 seconds)
Problem Description
In this problem, you are given two triangles and asked to determine if they are disjoint. Two triangles are not disjoint if there exists a common point inside or on the boundary of them.
Input Format
The first line has an integer which indicates the number of test cases. Each test case consists of two lines and each line contains the X- and Y-coordinates of the three vertices x1, y1, x2, y2, x3, y3 of a triangle. There is a space between two coordinates. Each coordinate is a real number which can be represented by a floating point variable.
Output Format
For each case, print “Disjoint” or “Not Disjoint” in one line accordingly.
Example
Sample Input:
3
0.0 0.0 1.0 0.0 0.0 2.0
0.0 0.0 -1.0 0.0 -1.0 -1.0
0.0 0.0 1.0 0.0 0.0 2.0
-0.5 -0.5 -1.0 0.0 -1.0 -1.0
0.0 0.0 1.0 0.0 0.0 2.0
0.1 0.1 0.1 0.2 0.5 0.5

Sample Output:
Not Disjoint
Disjoint
Not Disjoint

Problem 2. Counting the occurrences
(Time Limit: 20 seconds)
Problem Description
Given a string, you are asked to find the character which occurs more times than any other character in the string.
Input Format
The input consists of several lines, and each line is a string for one test case. Each string has no any space and its length is no more than 80 and at least one.
Output Format For each case, find the character and print it in one line. If there is no such character, output “None”.
Example
Sample Input:
abcdEABCE
123abc1231%^&*
AA22
Sample Output:
E
1
None
Problem 3. 阿姆斯壯數
(Time Limit: 20 seconds)
問題敘述 阿姆斯壯數 (Armstrong number) 又稱為narcissistic number或plus perfect number,是一個很神奇的數字!若某n位數的正整數X,其所有位數數字的n次方和與該數X相等,則該數X稱為阿姆斯壯數。
用數學表示: 若X= dndn-1...d2d1 當n位數的 di (1 ≤ i ≤ n) 滿足 0 ≤ di ≤ 9 其X= dn·10n-1 + dn-1·10n-2 + ... + d2·10 + d1 = dnn + dn-1n + ... + d2n + d1n 則X稱為阿姆斯壯數。 阿姆斯壯數是指該數(n位數)與該數之各位數的n次方和相等,則此數即為阿姆斯壯數。例如「1634」即為阿姆斯壯數:1634為四位數,而各位數的四次方和「1^4+6^4+3^4+4^4」正好為「1634」,因此1634是一個阿姆斯壯數。 請寫出一個程式,在輸入a和b後,列出a到b之間的所有阿姆斯壯數。
輸入說明 兩個正整數。
輸出說明 由小到大列出這兩個數字之間的所有阿姆斯壯數,數字之間隔一個空格。
範例
Sample Input:

100
900
Sample Output:
153 370 371 407
Problem 4. Treasure in a Maze
(Time Limit: 20 seconds)
Problem Description
Now, you have a treasure map, the map marked the location of the treasure in a maze. Known to enter the maze entrance will be closed automatically. Find a path to take the treasure (the shortest), and find a path to leave the maze (the shortest).
Input Format
An integer represents matrix size N.(less than 15)
The second line, two integers represent the coordinate (x, y) of the entry.
The third line, two integers represent the coordinate (x, y) of the exit.
The N x N integer matrix is the maze (0 is way, 1 is the treasure and, 9 is barrier).
The coordinate (x, y)
Output Format
Output two N x N matrix which display the path.
(0 is the way, 1 is the treasure, X is entry, Y is exit, * is the path and, 9 is barrier).
The first matrix is to find the treasure.
The second matrix is to find the exit.
Sample Input:
6
0 1
5 1
9 0 9 9 9 9
9 0 0 0 0 9
9 9 0 9 0 9
9 9 0 9 0 9
9 0 0 9 1 9
9 0 9 9 9 9
Sample Output:
9 X 9 9 9 9
9 * * * * 9
9 9 0 9 * 9
9 9 0 9 * 9
9 0 0 9 1 9
9 0 9 9 9 9
9 X 9 9 9 9
9 0 * * * 9
9 9 * 9 * 9
9 9 * 9 * 9
9 * * 9 1 9
9 Y 9 9 9 9
Problem 5. 就決定是你了!!
(Time Limit: 20 seconds)
問題敘述
在神奇寶貝世界裡,有一名怪獸馴服師名叫小智,他從小就立志要成為神奇寶貝大師,所以分析了神奇寶貝之間的關係,以下是他所分析的資料:
很多隻神奇寶貝都有他自己屬性,共有4種屬性地、水、火、風,每一隻神奇寶貝都有他自己的等級、血量、防禦、招式威力和出招速度,以上都會根據不同屬性有不同的量。血量的算法為:水屬性-等級*50+45,風屬性-等級*45+45,地屬性-等級*45+40,火屬性-等級*40+45;防禦算法:地屬性-等級*8+2,風屬性-等級*6+3,火和水屬性-等級*5+2,招式威力:火屬性-等級*20+30,地和水屬性-等級* 17+30,風屬性-等級*15+30;速度算法:風屬性-等級*10+10,火-等級*8+8,水-等級*7+9,地-等級*5+10。每個馴服師最多可帶三隻神奇寶貝,比賽的規則為算出身上每隻神奇寶貝的數值總合較大的為贏,若一樣則平手。每隻神奇寶貝數值算法:血量*0.5+防禦*1.5+招式*1.3+速度*2,請幫小智算出是否可以打贏對手。
例如 :單隻等級50、水屬性的神奇寶貝,血量為2545,防禦252 招式威力880 速度359整體數值為(2545*0.5 + 252*1.5 + 880*1.3 + 359*2)=3512.5
輸入說明
第一行為一個整數n ( 0 < n ≤ 16 )代表有幾個對手,之後有2n行,每兩行代表小智與對手,每一行的第一個數字k代表馴服師身上有k( 1 ≤ k ≤ 3 )隻神奇寶貝,之後有2k個數字分別代表每隻神奇寶貝的等級Lv (1 ≤ Lv ≤100)、屬性,屬性以1,2,3,4代表地,水,火,風。
輸出說明
如果小智可以獲勝則輸出win,不行則輸出lose,平手則輸出tie。
範例
Sample Input:
3
1 50 2
1 50 2
3 50 2 60 3 70 4
2 60 3 50 1
2 60 4 100 1
3 70 3 100 3 90 3
Sample Output:
tie
win
lose