結果
| 問題 |
No.1252 数字根D
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2020-10-09 23:48:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 422 bytes |
| コンパイル時間 | 410 ms |
| コンパイル使用メモリ | 82,348 KB |
| 実行使用メモリ | 76,972 KB |
| 最終ジャッジ日時 | 2024-07-20 14:38:51 |
| 合計ジャッジ時間 | 2,423 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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