a045: Fake Coins!! 偽造的金幣
標籤 : 迴圈
通過比率 : 88% (14 人 / 16 人 ) (非即時)
評分方式 :
Tolerant

最近更新 : 2019-04-09 08:54

內容

Among n bags of gold coins, one of them is counterfeit. We do not know which one is counterfeit, but we know counterfeit gold coins are lighter than real gold coins. Now we have a scale without scales that you can put more than one bags of gold coins on it. You need to weigh for a few times, then you can find out which bag of gold coins is counterfeit.

 

n 袋金幣中,有一袋金幣是偽造的,但我們不知道哪一袋金幣是偽造的金幣,我們知道偽造的金幣比真的金幣還輕,而手邊又正好只有沒有刻度的天秤,天秤的一端可放多袋金幣,聰明的你最多需要使用天秤幾次,保證一定能找出哪一袋是偽造的金幣。

輸入說明

The first line of the input contains an integer N (0 < N ≤ 20) indicating the number of test cases. For each test case, there is a line with one integer numbers n (2 ≤ n ≤ 1000000) representing how many bags of gold coins.

第一行為一個整數 N ( 0 < N ≤ 20 ) 代表有 N 組測試資料,之後會有 N 行數字,每一行數字代表 n ( 2 ≤ n ≤ 1000000 ) 袋金幣。

輸出說明

For each test case, the output is the maximum number of times you use the scale. Add a “newline” in the end of the output.

輸出 N 組測試資料可使用天秤的最多次數,最後必須有換行字元。

範例輸入
3
8
17
100
範例輸出
2
3
5
測資資訊 :
記憶體限制 : 64 MB
隱藏 測資點#0 (50%): 1.0s , <1K
隱藏 測資點#1 (50%): 1.0s , <1K
提示 :
標籤:
迴圈
出處:
ITSA_50th [編輯 :
shengZJ (shengZJ)
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」