結果
| 問題 |
No.434 占い
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-04-24 12:20:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 832 bytes |
| コンパイル時間 | 182 ms |
| コンパイル使用メモリ | 82,036 KB |
| 実行使用メモリ | 146,836 KB |
| 最終ジャッジ日時 | 2025-04-24 12:22:57 |
| 合計ジャッジ時間 | 6,640 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:
n = len(s)
if n == 1:
print(s[0])
continue
mod = 9
dp = [0] * n
dp[0] = 1
for i in range(n-1):
new_dp = [0] * (i + 2)
new_dp[0] = 1
new_dp[-1] = 1
for j in range(1, i + 1):
new_dp[j] = (dp[j-1] + dp[j]) % mod
dp = new_dp
total = 0
for i in range(n):
total = (total + int(s[i]) * dp[i]) % mod
if total == 0:
if any(c != '0' for c in s):
print(9)
else:
print(0)
else:
print(total)
if __name__ == "__main__":
main()
qwewe