結果

問題 No.434 占い
ユーザー roiti46roiti46
提出日時 2016-10-15 00:41:18
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-05-02 00:49:19
合計ジャッジ時間 3,468 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 21 ms
8,192 KB
testcase_02 AC 24 ms
8,192 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 22 ms
8,320 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 35 ms
8,320 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 88 ms
8,960 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 188 ms
8,320 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 93 ms
8,960 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

def pascal(n):
    line = [1]*(n + 1)
    for k in xrange(n):
        line[k + 1] = line[k]*(n - k)/(k + 1)
        if line[k + 1] >= 9: line[k + 1] %= 9
    return line

P = dict()
T = int(raw_input())
for loop in xrange(T):
    S = raw_input()
    N = len(S)
    if N == 1:
        print S
        continue
    if N not in P:
        p = pascal(N - 1)
        P[N] = p
    else:
        p = P[N]
    X = 0
    for i, s in enumerate(S):
        X += int(s)*p[i]
    print X
0