結果

問題 No.432 占い(Easy)
ユーザー nebukuro09nebukuro09
提出日時 2016-10-14 22:30:59
言語 Python2
(2.7.18)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 6,720 KB
実行使用メモリ 6,564 KB
最終ジャッジ日時 2023-08-14 11:06:33
合計ジャッジ時間 2,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,972 KB
testcase_01 AC 9 ms
6,004 KB
testcase_02 AC 10 ms
5,968 KB
testcase_03 AC 10 ms
6,120 KB
testcase_04 AC 11 ms
6,116 KB
testcase_05 AC 11 ms
6,160 KB
testcase_06 AC 10 ms
6,060 KB
testcase_07 AC 10 ms
6,208 KB
testcase_08 AC 10 ms
5,980 KB
testcase_09 AC 12 ms
5,988 KB
testcase_10 AC 12 ms
6,060 KB
testcase_11 AC 14 ms
6,044 KB
testcase_12 AC 54 ms
6,488 KB
testcase_13 AC 57 ms
6,560 KB
testcase_14 AC 16 ms
6,212 KB
testcase_15 AC 11 ms
6,056 KB
testcase_16 AC 11 ms
6,112 KB
testcase_17 AC 52 ms
6,564 KB
testcase_18 AC 31 ms
6,256 KB
testcase_19 AC 23 ms
6,196 KB
testcase_20 AC 16 ms
6,172 KB
testcase_21 AC 17 ms
6,116 KB
testcase_22 AC 11 ms
6,188 KB
testcase_23 AC 11 ms
5,992 KB
testcase_24 AC 13 ms
6,216 KB
testcase_25 AC 12 ms
6,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**3+10)

def f(a, b):
    return a+b if a+b < 10 else f(int(str(a+b)[0]), int(str(a+b)[1]))

mem = [[f(i, j) for j in xrange(10)] for i in xrange(10)]

def g(L, n):
    if n == 1:
        return L[0]
    for i in xrange(n-1):
        L[i] = mem[L[i]][L[i+1]]
    return g(L, n-1)

for i in xrange(input()):
    s = map(int, list(raw_input()))
    print g(s, len(s))
0