結果
問題 |
No.434 占い
|
ユーザー |
|
提出日時 | 2016-10-15 00:41:18 |
言語 | Python2 (2.7.18) |
結果 |
WA
|
実行時間 | - |
コード長 | 583 bytes |
コンパイル時間 | 544 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 9,088 KB |
最終ジャッジ日時 | 2024-11-22 09:39:07 |
合計ジャッジ時間 | 3,734 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 5 WA * 22 |
ソースコード
# -*- 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