e155. 10935 - Throwing cards away I
Tags :
Accepted rate : 1698人/1775人 ( 96% ) [非即時]
評分方式:
Tolerant

最近更新 : 2019-04-11 15:21

Content

給你一副照順序放好的紙牌,其中卡片的編號從1~n,且1號排在最上面,n號牌在最底下。
只要這副牌還有兩張以上,你就必須照以下的規則操作:

丟掉最上面的那張牌,然後把目前最上面的那張牌放到牌堆的最下面。
 
你的工作是找出每張牌被丟掉的順序,以及最後剩下的那張牌。
Input

輸入的每一列包含一個整數 n≤50,當輸入為0時代表輸入結束,你不應該處理這個輸入。

Output

對每個輸入的數字產生兩列輸出,第一列是每張牌被丟掉的順序,第二列則是剩下的那張牌。
任何一列都不應該有任何前置或尾隨的多餘空白,輸出細節請參考sample output。

Sample Input #1
7
19
10
6
0
Sample Output #1
Discarded cards: 1, 3, 5, 7, 4, 2
Remaining card: 6
Discarded cards: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 4, 8, 12, 16, 2, 10, 18, 14
Remaining card: 6
Discarded cards: 1, 3, 5, 7, 9, 2, 6, 10, 8
Remaining card: 4
Discarded cards: 1, 3, 5, 2, 6
Remaining card: 4
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (100%): 1.0s , <1K
Hint :
Tags:
出處:
UVa 10935 [管理者: qqrainbow(愛蜜莉雅) ]


ID User Problem Subject Hit Post Date
31770 406490150@gm...(我是朱朱) e155
[Python]deque
238 2022-08-18 15:31
31759 cccccsssss(CS) e155
237 2022-08-17 22:04
29925 kurosakii.cv...(Zero Kurosakii) e155
想法
465 2022-04-12 10:38
26663 ck1090758@gl...(peienwu) e155
解題思路
894 2021-08-19 12:27
22599 fastrvretk@g...(Abas Tanmia) e155
注意當n=1時
1851 2020-09-18 15:27