結果

問題 No.1252 数字根D
ユーザー yuusanlondonyuusanlondon
提出日時 2020-10-09 22:09:04
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 298 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 78,400 KB
最終ジャッジ日時 2023-09-27 17:25:35
合計ジャッジ時間 2,872 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,316 KB
testcase_01 AC 73 ms
71,316 KB
testcase_02 AC 73 ms
71,456 KB
testcase_03 AC 97 ms
75,928 KB
testcase_04 AC 119 ms
78,096 KB
testcase_05 AC 114 ms
78,400 KB
testcase_06 AC 116 ms
78,376 KB
testcase_07 AC 116 ms
78,264 KB
testcase_08 AC 117 ms
78,308 KB
testcase_09 AC 117 ms
78,016 KB
testcase_10 AC 117 ms
78,288 KB
testcase_11 AC 116 ms
78,024 KB
testcase_12 AC 116 ms
78,152 KB
testcase_13 AC 116 ms
78,244 KB
testcase_14 AC 72 ms
71,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
    
0