結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
7,784 KB
testcase_01 AC 21 ms
7,768 KB
testcase_02 AC 20 ms
7,860 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 23 ms
7,712 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 35 ms
7,916 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 90 ms
8,444 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 166 ms
7,852 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 94 ms
8,428 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]
        if X > 9: X %= 9
    print X 
0