結果
| 問題 |
No.3308 One-time Changed Formula
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-28 17:31:33 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 728 bytes |
| コンパイル時間 | 257 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2025-10-28 17:31:37 |
| 合計ジャッジ時間 | 2,885 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 14 |
ソースコード
def process_string(s: str) -> int:
ans = 0
shift_flag = False
for ch in s:
if ch.isdigit():
digit = int(ch)
ans += digit - 1 if shift_flag else 9 - digit
elif ch == '*':
if not shift_flag:
ans += 9
elif ch == '-':
if not shift_flag:
ans += 9
shift_flag = True
elif ch == '+':
if not shift_flag:
ans += 9
shift_flag = False
return ans
def main():
t = int(input())
for _ in range(t):
parts = input().split()
s = parts[-1] # take the string, ignore n
print(process_string(s))
if __name__ == "__main__":
main()