結果

問題 No.434 占い
ユーザー roiti46roiti46
提出日時 2016-10-15 00:36:22
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 650 bytes
コンパイル時間 1,785 ms
コンパイル使用メモリ 77,312 KB
実行使用メモリ 103,808 KB
最終ジャッジ日時 2023-08-14 12:24:22
合計ジャッジ時間 10,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
92,044 KB
testcase_01 AC 158 ms
92,292 KB
testcase_02 AC 162 ms
92,440 KB
testcase_03 AC 160 ms
92,244 KB
testcase_04 AC 158 ms
92,532 KB
testcase_05 AC 158 ms
92,376 KB
testcase_06 AC 172 ms
92,280 KB
testcase_07 AC 163 ms
92,336 KB
testcase_08 AC 238 ms
103,768 KB
testcase_09 AC 168 ms
93,068 KB
testcase_10 AC 171 ms
93,176 KB
testcase_11 AC 179 ms
93,396 KB
testcase_12 AC 198 ms
94,856 KB
testcase_13 AC 232 ms
103,808 KB
testcase_14 AC 165 ms
93,176 KB
testcase_15 TLE -
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]
    ans = 0
    for x in str(X):
        ans = ans + int(x)
        if ans >= 10:
            ans = ans%10 + 1
    print ans
0