結果
問題 |
No.3118 Increment or Multiply
|
ユーザー |
|
提出日時 | 2025-04-21 00:24:16 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 609 bytes |
コンパイル時間 | 543 ms |
コンパイル使用メモリ | 82,536 KB |
実行使用メモリ | 78,960 KB |
最終ジャッジ日時 | 2025-04-21 00:24:22 |
合計ジャッジ時間 | 5,890 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 35 |
ソースコード
import sys input = sys.stdin.readline MOD = 998244353 T = int(input()) NA = [list(map(int, input().split())) for _ in range(T)] for n, a in NA: if a==1: ans = (n-1)*n//2 print(ans) else: y = n ans = 0 m = [] first = 1 cnt = 0 while y>0: x = y//a if first: ans += (n-(x+1))*(n-x)//2 first = 0 else: ans += (y-(x+1))*(y-x)//2 ans += (y-x)*cnt + sum(m) m.append(y%a) y = x cnt += 1 print(ans%MOD)