結果

問題 No.434 占い
ユーザー roiti46roiti46
提出日時 2016-10-15 00:43:15
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 6,552 KB
実行使用メモリ 590,360 KB
最終ジャッジ日時 2023-08-14 12:33:40
合計ジャッジ時間 4,855 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
12,176 KB
testcase_01 AC 23 ms
7,744 KB
testcase_02 AC 23 ms
7,764 KB
testcase_03 WA -
testcase_04 AC 24 ms
7,752 KB
testcase_05 AC 24 ms
7,940 KB
testcase_06 AC 25 ms
7,744 KB
testcase_07 WA -
testcase_08 AC 122 ms
17,652 KB
testcase_09 AC 37 ms
7,916 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 38 ms
7,812 KB
testcase_13 AC 122 ms
17,588 KB
testcase_14 AC 35 ms
8,036 KB
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

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)
    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]
        if X > 9: X %= 9
    print X 
0