結果
問題 |
No.434 占い
|
ユーザー |
![]() |
提出日時 | 2025-04-24 12:20:45 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 694 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 82,692 KB |
実行使用メモリ | 267,616 KB |
最終ジャッジ日時 | 2025-04-24 12:22:39 |
合計ジャッジ時間 | 5,256 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 11 TLE * 1 -- * 15 |
ソースコード
import sys def main(): input = sys.stdin.read().split() T = int(input[0]) cases = input[1:T+1] for s in cases: m = len(s) if m == 1: print(s) continue prev = [1] for n in range(1, m): current = [1] * (n + 1) for k in range(1, n): current[k] = (prev[k-1] + prev[k]) % 9 prev = current total = 0 for i in range(m): digit = int(s[i]) coeff = prev[i] % 9 total += digit * coeff total %= 9 print(9 if total % 9 == 0 else total % 9) if __name__ == '__main__': main()