結果
| 問題 | No.1252 数字根D |
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2020-10-09 23:48:48 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 422 bytes |
| 記録 | |
| コンパイル時間 | 235 ms |
| コンパイル使用メモリ | 85,316 KB |
| 実行使用メモリ | 139,468 KB |
| 最終ジャッジ日時 | 2026-04-03 00:31:56 |
| 合計ジャッジ時間 | 1,535 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 14 |
ソースコード
t = int(input())
for _ in range(t):
d, a, b = map(int, input().split())
s = (d-1)*d//2
c = b-a+1
q, r = divmod(c, d-1)
#print(q, r)
if (a-1)%(d-1) == 0:
ans = s*q+r*(r+1)//2
else:
p = (a-1)%(d-1)
r1 = (d-1)-p
if r1 <= r:
r2 = b%(d-1)
ans = s*q+s-p*(p+1)//2+r2*(r2+1)//2
else:
ans = s*(q-1)+s-p*(p+1)//2
print(ans)
brthyyjp