結果
| 問題 |
No.1252 数字根D
|
| コンテスト | |
| ユーザー |
yuusanlondon
|
| 提出日時 | 2020-10-09 22:09:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 2,000 ms |
| コード長 | 298 bytes |
| コンパイル時間 | 230 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 76,288 KB |
| 最終ジャッジ日時 | 2024-07-20 11:44:51 |
| 合計ジャッジ時間 | 2,035 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
t=int(input())
for _ in range(t):
d,a,b=map(int,input().split())
ans=b-a+1
a-=1
b-=1
first=a%(d-1)
last=b%(d-1)
ans+=(((d-2)*(d-1))//2)*(b//(d-1))
ans-=(((d-2)*(d-1))//2)*(a//(d-1))
ans+=((last*(last+1))//2)
ans-=((first*(first-1))//2)
if a==-1:
ans-=d-1
print(ans)
yuusanlondon