結果

問題 No.560 ふしぎなナップサック
ユーザー fagfagdfa
提出日時 2017-08-25 23:34:00
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 858 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 66,640 KB
最終ジャッジ日時 2024-10-15 16:13:38
合計ジャッジ時間 3,485 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 TLE * 1 -- * 1
other -- * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

def bfs(N, que, dic):
    if N == 0:
        return que, dic
    tmp = []
    dic = {}
    while len(que) != 0:
        x = que.pop(0)
        a = x + 1
        b = x * 2
        c = 0
        if a not in dic:
            dic[a] = 1
            tmp.append(a)
        else:
            dic[a] += 1
        if b not in dic:
            dic[b] = 1
            tmp.append(b)
        else:
            dic[b] += 1
        if c not in dic:
            dic[c] = 1
            tmp.append(c)
        else:
            dic[c] += 1
    for i in tmp:
        que.append(i)
    return bfs(N - 1, que, dic)

if __name__ == '__main__':
    N, M = map(int, raw_input().split())
    dic = {}
    que = []
    que.append(N)
    rt1, rt2 = bfs(M, que, dic)

    key = rt2.keys()
    tmp = 0
    for i in key:
        tmp += rt2[i]

    print float(float(sum(rt1)) / float(tmp))
0