結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー hosobikihosobiki
提出日時 2018-07-05 15:32:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,366 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 8,436 KB
最終ジャッジ日時 2023-09-13 17:45:28
合計ジャッジ時間 1,889 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 15 ms
7,924 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys
import math

def main():
    text = sys.stdin.readline()
    biscuits_n =  int(text)

    biscuits_inp = 1
    biscuits_outp = 0
    biscuits_total = biscuits_inp + biscuits_outp
    tap_count = 0
    tap_total = 0
    
    while biscuits_n > biscuits_total:
        #ポケットをたたく回数算出
        if (biscuits_n - biscuits_total) == 1:
            tap_count = 1
        else:
            tap_count = math.floor((math.log10(biscuits_n - biscuits_outp) - math.log10(biscuits_inp)) / math.log10(2))
        tap_total +=  tap_count
        
        #"ビスケットを増やす"
        biscuits_inp = pow(biscuits_inp * 2,tap_count)
        biscuits_total = biscuits_inp + biscuits_outp
        
        #ビスケットをポケットの外に出す
        biscuits_outp += biscuits_inp
        biscuits_inp = 0
        
        #増やすビスケットをポッケの中に戻す
        if (biscuits_n - biscuits_total) == 1.0 :
            biscuits_inp = 1.0
        else:
            biscuits_inp = math.floor(biscuits_n - biscuits_outp)
        biscuits_outp -= biscuits_inp
        
        print("tap:" + str(tap_count),"total biscuits:" + str(biscuits_total),"outside poket:" + str(biscuits_outp),"inside poket:" + str(biscuits_inp))
        
    print(tap_total)
    
if __name__ == "__main__":
    main()
0