結果

問題 No.434 占い
ユーザー roiti46
提出日時 2016-10-15 00:36:22
言語 PyPy2
(7.3.15)
結果
MLE  
実行時間 -
コード長 650 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 630,176 KB
最終ジャッジ日時 2024-11-22 09:25:23
合計ジャッジ時間 19,035 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 MLE * 2
other AC * 23 TLE * 3 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

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