結果

問題 No.434 占い
ユーザー roiti46roiti46
提出日時 2016-10-15 00:41:18
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 6,684 KB
実行使用メモリ 8,652 KB
最終ジャッジ日時 2023-08-14 12:33:26
合計ジャッジ時間 3,543 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 23 ms
7,872 KB
testcase_02 AC 22 ms
7,796 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 25 ms
7,760 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 39 ms
7,920 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 96 ms
8,516 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 179 ms
7,784 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 95 ms
8,568 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