結果

問題 No.1918 Simple Math ?
ユーザー とりゐとりゐ
提出日時 2022-04-09 01:04:25
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 154,508 KB
最終ジャッジ日時 2023-09-11 11:32:23
合計ジャッジ時間 6,932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
83,940 KB
testcase_01 AC 81 ms
76,136 KB
testcase_02 AC 80 ms
76,304 KB
testcase_03 AC 82 ms
76,116 KB
testcase_04 AC 78 ms
76,164 KB
testcase_05 AC 80 ms
76,188 KB
testcase_06 AC 100 ms
84,324 KB
testcase_07 AC 115 ms
88,156 KB
testcase_08 AC 95 ms
82,120 KB
testcase_09 AC 90 ms
79,092 KB
testcase_10 AC 101 ms
83,828 KB
testcase_11 AC 80 ms
76,448 KB
testcase_12 AC 108 ms
86,668 KB
testcase_13 AC 99 ms
82,880 KB
testcase_14 AC 92 ms
80,216 KB
testcase_15 AC 85 ms
77,764 KB
testcase_16 AC 171 ms
109,728 KB
testcase_17 AC 177 ms
112,236 KB
testcase_18 AC 213 ms
125,356 KB
testcase_19 AC 219 ms
129,184 KB
testcase_20 AC 197 ms
119,840 KB
testcase_21 AC 278 ms
151,060 KB
testcase_22 AC 276 ms
150,088 KB
testcase_23 AC 272 ms
149,764 KB
testcase_24 AC 274 ms
149,684 KB
testcase_25 AC 275 ms
150,460 KB
testcase_26 AC 171 ms
154,508 KB
testcase_27 AC 285 ms
154,188 KB
testcase_28 AC 205 ms
121,952 KB
testcase_29 AC 75 ms
71,672 KB
testcase_30 AC 75 ms
71,432 KB
testcase_31 AC 273 ms
154,400 KB
testcase_32 AC 80 ms
75,900 KB
testcase_33 AC 80 ms
76,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
for _ in range(int(input())):
  a,n=map(int,input().split())
  m=math.isqrt(a*n)
  c=[0]*(a+1)
  for i in range(1,a+1):
    c[i]=c[i-1]+(i*i-1)%a
  p,q=m//a,m%a
  ans=m*(2*m*m+3*m-5)//6-c[a]*p-c[q]
  print((n*m-ans//a)%(10**9+7))
0