574 - 簡單題大賽 Scoreboard

Time

2015/03/06 19:00:00 2015/03/06 22:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

1000 - The A+B Problem   

Description

Given a,b, output a+b.

Input

a,b<=100000000.

Output

a+b

Sample Input  Download

Sample Output  Download

Tags

4 5 ddd 3 a #include <stdio.h> p klrscpp ? CCY rain orange CAH happy 我問號



Discuss




1001 - Simple Relation   

Description

Given two integer sequences A, B. Add them in some specific order O.
O is described via a representation of the location relationship from input.

For example, O = 100101 means A[i] + B[i+2] write to result C[i+1];
O = 111 means A[i] + B[i] write to C[i].

Note that if index is out of the length of B or C, imagine that B,C are circular.

Input

N
L
A
B
O

N is the number of total test data.
L is the number of element in A,B.

A,B sequences have the same number of elements, each element e:
0< e < 1000000
1<= num. of A,B <= 1000

O is the description of the order
3 <= length of O < 1000
there are exactly three ones in O, and the leading one is always happen!

Output

Output your result by the same format of input sequence.

Sample Input  Download

Sample Output  Download

Tags

klrscpp



Discuss




1002 - String Reverse   

Description

Given a string S, output the reverse of S.

Input

The input consists of many lines. Each line is a string S with length <= 1000000.
The string S does not contain any spaces.

Output

Output the the reverse of S. One in each line.

Sample Input  Download

Sample Output  Download

Tags

klrscpp sss



Discuss




1003 - OTAKU   

Description

"Otaku" is a Japanese term used to refer to people with obsessive interests, particularly anime,
manga, and video games. Otaku usually has much features such that you can recognize someone as
a otaku with those features.


Dr.Davidsu now want to do a research about Otaku. First he wants a program to help him.
The program should read the list of characteristics of many people and to determine how possible
they are Otaku.

Although Dr.Davidsu is a great programmer, but since he realizes so much knowledge about Otaku
with his research, now he also becomes a OTAKU!! So he only plays games day and night and could
not write program anymore. Please help the great Ota.. uh.. great Dr. Davidsu!!

Input

There are two positive integer N, M in the first line of input following N lines of the features of Otaku.
Each line has a distinct string describes the feature. And then there are M people's describing below.
In each people's data, first line there is a positive integer K which is the number of the people's characteristics
and K lines below are the K features of the people. 

Limits

1 <= N <= 10000
1 <= M <= 1000
1 <= K <= 1000

the string describes the feature of otaku or people is consecutive characters only contains uppercase

letter or underline char "_"  and no more than 16 characters.

Output

For each people, if more than half of its characteristics is a feature of OTAKU, then output 'Y'.
Otherwise output 'N' on each line.

Sample Input  Download

Sample Output  Download

Tags

Otaku



Discuss




7003 - 連續和問題   

Description

給你一個連續非負整數陣列A = {a1, a2, …, aN},已知0 < a1+ a2+ …+ aN < 231,給定一個數字x,請寫一個程式判斷陣列A中是否存在連續和ai + ai+1+…+aj = x?(注意:連續和至少包含一個陣列元素)

Input

第一行有一個正整數 T (T <= 50),表示接下來有T筆測試資料。

每一筆測資資料都有三行資料,第一行有一個正整數N (N < 500,000) 表示陣列A的長度是N。第二行有一個整數x (0 <= x < 231),代表題目中的x值。第三行有N個整數,每個整數的範圍介於 (0 <= x < 231),且兩個整數之間以一隔空白隔開。

Output

每筆測資各占一行,如果存在一個連續和為x,輸出Yes,反之輸出No

Sample Input  Download

Sample Output  Download

Tags




Discuss




7007 - 榜單查詢   

Description

大學學測放榜,教育部查榜系統提供一種查詢方式,輸入名次k,將列出該名次的總分以及所有排名為第k名的同學,


因為相同名次的同學很多,所以該系統統一以准考證號碼的順序來排列。

舉例來說,假設有5位學生:Mary, John, Ben, Alice, Gill
以下是他們的排名

名次 名字 分數
1 John 300
2 Mary 285
2 Gill 285
4 Alice 250
5 Ben 200
 
如果今天要查第2名,我們會查到Mary和Gill。
如果要查第4名,則會查到Alice。
 

Input

只有一組測資。
第一行有2個數字N (N <= 200,000) 代表學生總人數, Q (Q <= 50) 代表查詢名次的次數
接下來的N行代表按照准考證號碼順序排列的學生。
每行有學生的姓名 (只包含長度16以內的大小寫英文字母) 以及考試成績 (0~1000分的整數)

接下來有Q行,每行只有一個數字k (k > 0),表示要查詢第k名的資訊

Output

一共有Q組輸出,每組的第一行輸出Query #i: 考試成績,i表示第幾個查詢,若輸入的名次k不存在,在考試成績的部分輸出null。
接下來幾行輸出該名次的同學名字(各佔一行)。

Sample Input  Download

Sample Output  Download

Tags




Discuss




7029 - 爬樓梯   

Description

長短腳叔叔在爬樓的時候為了避免跌倒,他的左腳只爬奇數個階梯(1, 3, 5, ...),右腳只爬偶數個階梯(2, 4, 6, ...),最多可以一次爬2K個階梯

當然身為一個正常的大叔,走路不會故意連續走兩個左腳或連續走兩個右腳,一定是一左一右交替著走,

在一個不知名的山上寺廟前有N階樓梯,請問他有幾種走法可以爬到山上?

舉例來說,假如N=5, K = 2

長短腳叔叔可以{左腳1階, 右腳4階}, {左腳3階, 右腳2階}, {右腳2階, 左腳3階}, {右腳2階, 左腳1階, 右腳2階}, {右腳4階, 左腳1階}

一共有5種走法

Input

輸入第一行包含一個整數T (T < 100) 表示接下來有幾筆測資。

接下來的每組測資都有兩個數字:

N (1 <= N <= 1000)表示有幾階樓梯, 

K (1 <= K <= 50)表示他左腳可以走{1, 3, 5, ..., 2K-1}階樓梯,右腳可以走{2, 4, 6, ... 2K}階樓梯

Output

每組輸出一行輸出有幾種走法可以爬到山上,因為走法可能太多,

假設一共有X種走法,請輸出X%12345678來表示所有走法

Sample Input  Download

Sample Output  Download

Tags




Discuss




7115 - 清大狗博士布魯師的煩惱   

Description

布魯師是清大狗博士,他對於清大的校狗有很深的了解。根據他多年的觀察,他發現

校狗分很多幫派,布魯師想了一個很聰明的方法,他認為只要對每個幫派的其中一隻

狗下命令,通過他們彼此之間的訊息傳達,所有的狗就知道布魯師下了什麼的命令。

但是布魯師只知道任兩隻狗是不是同幫派的關係,他想請你幫他寫程式計算清大到底

有幾個狗幫派。

 

Input

每行會有兩個字串,代表兩個校狗的名字,也代表這兩隻狗之間是同幫派

如果讀到#,表示這組測資結束

每組測資最少有一種關係

每一行兩隻狗名不會相同

狗的名稱只會有大小寫英文字母

測資最多有200組,每組最多有70行,校狗最多有30隻,最少2隻, 校狗名稱最多20個英文字母
 

Output

對於每一筆測資輸出"Case i: n",表示有幾個不同的幫派。

Sample Input  Download

Sample Output  Download

Tags




Discuss




7121 - 博物館神偷   

Description

阿星是神偷專業協會 (Thief Professional Committee) 的會員之一,這個協會每年都會舉辦一次偷盜大賽,比賽的規則如果

  1. 每位參賽者會發配一個有限空間的黑色布袋,假設該布袋容量為R,一旦裝太多東西,很有可能會被警察抓到,所以身為一個專業的小偷是不會讓自己超載。
  2. 每個人都可以從任務欄上選一張收藏品清單,清單裡面有每個博物館收藏品的大小以及該物品的價值
  3. 比賽限時一個晚上,統計出每位參賽者總共偷了價值多少的收藏品
  4. 而偷到收藏品價值總和最多的會員,就是該年度的MVP

阿星很想要得到這個稱號來證明自己高超的偷術,但是他不知道要怎麼樣才能在不超載(收藏品總大小不超過R)的情況下,哪一張清單才能偷到總價值最多的收藏品,他希望你能告訴他每一張清單在總大小R以內最多可以的收藏品總價值。

Input

第一行表示公佈欄上有T (T <= 100)張清單,以及布袋容量R (R <= 100)

接下來每一張清單的第一行有一個數字N (N <= 100)表示清單上有N個收藏品,之後的N行中,每行都有兩個數字Wi (1 <= Wi <= 100), V(1 <= Vi <= 1,000,000)表示該收藏品的大小以及價值。

Output

每一行都要輸出List i: value的形式,其中i表示第i張清單,value表示這張清單中可以偷取最多總價值多少的收藏品,詳情請看Sample Output

Sample Input  Download

Sample Output  Download

Tags




Discuss




7225 - PB - A+B   

Description

NTHU OJ 第1000 題的題目是 A+B,題目是請大家輸出A+B 的值,這題因為很
簡單,所以有很多人去做。不過Alan 最近在改judge 網頁,不小心把Rank List
的網頁改爛了,所以現在網頁的Rank List 沒有依照程式執行速度排序,你可以
幫Alan 寫個排序,把Rank List 重新改好嗎?

Input

多組測資,每組測資第⼀行有個整數n(n<100000)表示解題人數,接下來n 行每
行代表⼀個解題者的資訊,第⼀個字串是User ID(長度<20 的大小寫英文字母與
數字),第二個字串是CPU Time(正浮點數,到小數後第三位)。

Output

對於每組測資請依照CPU Time 排序,輸出名次(從1 開始排)、User ID、CPU
Time(輸出到小數點後三位),中間以空白隔開;如果CPU Time 相同,先出現的要排前面

Sample Input  Download

Sample Output  Download

Tags




Discuss




7488 - 哪種三角形?! (II)   

Description

Kerker正在教國小的小妹妹判斷三角形,你可以寫一個程式幫他判斷是哪種三角形嗎??

Input

第一行是測試資料的組數T,接下來有T筆測試資料
每筆測試資料佔一行,分別有3個整數 a,b,c代表三角形的三條邊.
a,b,c 屬於 32 bit signed number

Output

如果輸入的三條邊:
1. 不合法 : 請輸出 : Oh~NO!!
2. 正三角形 : 請輸出 : 3 equal
3. 等腰三角形 : 請輸出 : 2 equal
4. 可以組成三角形但不是等腰或正三角 : 請輸出 : OK!

Sample Input  Download

Sample Output  Download

Tags




Discuss




7489 - Unlucky 37!! (II)   

Description

Kerker想幫可愛的小妹妹挑一些幸運數字,你可以幫他把不幸的數字除掉嗎?

題目會給你一個數字N
請輸出
1. 大於0
2. 整數
3. 不可以被3或7整除
4. 數字裡面不能出現3或7
5. 小於N
的所有幸運數字

Input

有多筆測試資料,每組測試資料一行.
1 < N < 10000

Output

如題目敘述輸出所有可能的數字
一組測試資料輸出一行
數字間以一個空白隔開
輸出的每筆答案間以一個空行隔開

Sample Input  Download

Sample Output  Download

Tags




Discuss




7490 - Counting Game (II)   

Description

請算出每一行中有幾個大寫英文字母結尾的字(Word)
Word的定義是連續英文字母所組成的字

Input

有多組測資,每組測資一行,每行長度不超過500。

Output

輸出每一行由大寫英文字母結尾的Word數。

Sample Input  Download

Sample Output  Download

Tags




Discuss




7492 - 最後的紅線!(II)   

Description

有一天,小明看著手邊兩堆長度分別相同的紅線,說:I want to play a game.
(謎:Play 啥米game?)
遊戲內容如下:
1. 從兩堆紅線各取一條放在桌上。
2. 比較兩條線,選較短的那邊,從與其組成相同的那堆裡取一條接上去。
3. 重複步驟2. 直到兩條紅線長度相等。
假設兩堆紅線的量和桌子的長度都是無限大,給定一開始兩堆紅線的單位長度,請寫一個程式判斷最後的紅線的長度。

Input

有多筆測試資料,每筆資料會有一行,包含兩個正整數m, n (1≦m, n≦10,000,000),中間以空白隔開,分別代表兩堆紅線的單位長度。

Output

每筆測資一行,輸出最後的紅線的長度。

Sample Input  Download

Sample Output  Download

Tags




Discuss




7502 - 2 5 6 9 @@(I)   

Description

對CS的學生而言,數學是很重要的科目,如果連2,5,6,9都分不出來,一定會有被當的危機!
給你多個數字,請依照下列格式用印出每個數字。

2:
22222
       2
22222
2       
22222

5:
55555
5
       
55555
       5
55555

6:
66666
6
       
66666
6     6
66666

9:
99999
9     9
99999
       9
99999

Input

第一行為N,代表測資數。每組測資有I*J個數字(1<=I, J<=20),每個數字間以一空白隔開,每組測資後有一空白行。
測資中不會有多餘的空白,亦不會出現2,5,6,9外的數字。

Output

每組測資請照順序輸出用2/5/6/9組成的數字。每列輸出I個數字,每個數字大小皆為5*5(不需要填入2/5/6/9的部分請填入空白),數字間以一空白隔開,每行數字後輸出一空白行。

Sample Input  Download

Sample Output  Download

Tags




Discuss




7531 - From the New World!!   

Description

<<來自新世界 - 對抗虛偽的神>>這部動畫是kerker這幾年來認為最最好看的一部!!在kerker心裡是神作等級的!!!!裡面描述了1000年後的人類世界…主角們住在神棲66町 , 這城鎮劃分為3000*3000個小方格以方便管理 , 左上角那一格是(1,1) , 右下角那格則是(3000,3000) .
城鎮外則住了許多怪異的生物 , 最主要的是化鼠這一個族群 , 化鼠族群日益壯大 , 就在今晚 , 他們打算攻進人類的城鎮裡!!!但是人類們可不是好惹的 , 在1000年後的世界 , 人類擁有"咒力"這一項超強的武器 , 當人類使用咒力時 , 可以把距離這位人類10步以內的化鼠全部消滅!!(他不會打到人類同伴的!!否則….請看動畫XD)假設人類所在的座標是(x,y) , 化鼠所在的座標是(a,b) , 則絕對值(x-a) + 絕對值(y-b)只要小於等於10就可以把那隻化鼠消滅!!
大戰才剛開始 , 化鼠軍隊挾著大量的優勢進攻 , 數以萬計的化鼠不斷奔來 , 反觀人類部落 , 有能力防守的卻只有不到1000人…能請你幫忙算算人類到底能消滅幾隻化鼠嗎??
請注意 : 此題的input非常的大 , 切勿使用cin做讀取. 建議寫之前一定要先估算複雜度.

Input

有多組測資,每組測資第一行有兩個數字H和M , H代表有多少個人類能進行防禦 , M代表有多少隻化鼠在地圖上.(0<=H<1000 , 0<=M<=10^6)
接下來H行 , 每行為一個人類所在的座標x y (1<=x,y<=3000) , 接下來M行每行代表一隻化鼠的座標x y (1<=x,y<=3000) . 座標皆有可能重複!!(表示一個座標格內可以有多個人和多隻化鼠)

Output

每組測資輸出人類能殺死幾隻化鼠 , 一組測資輸出一行.

Sample Input  Download

Sample Output  Download

Tags




Discuss




7538 - From the New World!!(II)   

Description

<<來自新世界 - 對抗虛偽的神>>這部動畫是kerker這幾年來認為最最好看的一部!!在kerker心裡是神作等級的!!!!裡面描述了1000年後的人類世界…主角們住在神棲66町 , 這城鎮劃分為3000*3000個小方格以方便管理 , 左上角那一格是(1,1) , 右下角那格則是(3000,3000) .
城鎮外則住了許多怪異的生物 , 最主要的是化鼠這一個族群 , 化鼠族群日益壯大 , 就在今晚 , 他們打算攻進人類的城鎮裡!!!但是人類們可不是好惹的 , 在1000年後的世界 , 人類擁有"咒力"這一項超強的武器 , 當人類使用咒力時 , 可以把距離這位人類10步以內的化鼠全部消滅!!(他不會打到人類同伴的!!否則….請看動畫XD)假設人類所在的座標是(x,y) , 化鼠所在的座標是(a,b) , 則絕對值(x-a) + 絕對值(y-b)只要小於等於10就可以把那隻化鼠消滅!!
大戰剛剛打完一輪 , 第一梯的同學們已經消滅掉非常多的化鼠了 , 現在化鼠們已經剩不到1000隻了!!!人類其他部落也派來了更多的援兵!!但人類仍然必須把剩下的化鼠盡可能的消滅掉!!!能請你算算在最後 , 人類能消滅幾隻化鼠嗎??
請注意 : 此題的input非常的大 , 切勿使用cin做讀取. 建議寫之前一定要先估算複雜度.

Input

有多組測資,每組測資第一行有兩個數字M和H , H代表有多少個人類能進行防禦 , M代表有多少隻化鼠在地圖上.(0<=M<1000 , 0<=H<=10^6)
接下來M行 , 每行為一隻化鼠所在的座標x y (1<=x,y<=3000) , 接下來H行每行代表一個人類的座標x y (1<=x,y<=3000) . 座標皆有可能重複!! (表示一個座標格內可以有多個人和多隻化鼠)

Output

每組測資輸出人類能殺死幾隻化鼠 , 一組測資輸出一行.

Sample Input  Download

Sample Output  Download

Tags




Discuss




7543 - PA - Challenge your IQ!!(I)   

Description

這一題源自網路上的某個智力測驗~kerker當初看到這題的時候 , 想說我不夠聰明解不出來 , 但是kerker有電腦這項超強的武器!!靠電腦解決問題才是CS的學生阿阿阿!!!

當然如果你的智力夠高 , 可以直接用大腦解出來也是可以的>.^

畢竟 , 這題的答案是唯一的!!


請回答下面10個問題 , 每題都"恰"有一個答案是正確的 :
1 第一個答案是b的問題是哪一個?
(a)2 (b)3 (c)4 (d)5 (e)6
2 唯一的連續兩個具有相同答案的問題是:
(a)2,3 (b)3,4 (c)4,5 (d)5,6 (e)6,7
3 本問題答案和哪一個問題的答案相同?
(a)1 (b)2 (c)4 (d)7 (e)6
4 答案是a的問題的個數是:
(a)0 (b)1 (c)2 (d)3 (e)4
5 本問題答案和哪一個問題的答案相同?
(a)10 (b)9 (c)8 (d)7 (e)6
6 答案是a的問題的個數和答案是什麼的問題的個數相同?
(a)b (b)c (c)d (d)e (e)以上都不是
7 按照字母順序,本問題的答案和下一個問題的答案相差幾個字母?
(a)4 (b)3 (c)2 (d)1 (e)0  (註:a和b相差一個字母)
8 答案是母音字母的問題的個數是:(註:a和e是母音字母)
(a)2 (b)3 (c)4 (d)5 (e)6
9 答案是子音字母的問題的個數是:
(a)一個質數 (b)一個階乘數 (c)一個平方數 (d)一個立方數 (e)5的倍數
10 本問題的答案是:
(a)a (b)b (c)c (d)d (e)e

Input

沒有input : )

Output

輸出一行 , 分別是第一題到第十題的答案 , 答案”間”請以一個空白隔開 , 請使用小寫字母. 輸出完後請換行.
舉例 : printf(“%c %c …….. %c ”,ans1,ans2,…..ans10);

Sample Input  Download

Sample Output  Download

Tags




Discuss




9048 - GCD   

Description

Given two positive integers a and b, compute the greatest common divisor (GCD) of a and b. The GCD of a and b is the biggest integer that can divide a and b with no reminder.

Input

First line contains a positive integer t (t<=1000), which indicates the number of test cases in the input. In the next t lines, each line contains two positive integers a, b, which are smaller than or equal to 106.

Output

For each case, output the GCD of a and b in a line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




9084 - Box and Money   

Description

There are many boxes.  In each box; there are treasures of different values.  Make a list of these boxes, in which they are sorted by the total value of treasures in them from large to small.  If two boxes have the same total value, the one appearing earlier in the input data should be output first.  And in each box, list the treasures values from small to large.

Input

There are multiple test cases.  Each case begins with an integer N (1 <= N <= 104) which represents the number of boxes.  In the next N lines, each line contains a sequence of positive integers, representing the value of the treasures. There are at most 103 treasures in one box. Each line is terminated by 0.  The input is terminated by N = 0 in a single line.

Output

For each test case, output the sorted boxes in N lines.  In each line, output a sequence of sorted integers, representing the values of treasures.  Use a blank line to separate two test cases.

Sample Input  Download

Sample Output  Download

Tags




Discuss