結果

問題 No.1918 Simple Math ?
ユーザー とりゐとりゐ
提出日時 2022-04-14 23:38:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 154,536 KB
最終ジャッジ日時 2023-09-11 11:32:31
合計ジャッジ時間 6,795 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
83,904 KB
testcase_01 AC 84 ms
76,200 KB
testcase_02 AC 81 ms
76,116 KB
testcase_03 AC 83 ms
76,336 KB
testcase_04 AC 81 ms
76,132 KB
testcase_05 AC 80 ms
76,384 KB
testcase_06 AC 100 ms
84,144 KB
testcase_07 AC 115 ms
88,060 KB
testcase_08 AC 97 ms
81,888 KB
testcase_09 AC 90 ms
79,256 KB
testcase_10 AC 103 ms
84,136 KB
testcase_11 AC 81 ms
76,488 KB
testcase_12 AC 114 ms
87,112 KB
testcase_13 AC 98 ms
82,820 KB
testcase_14 AC 91 ms
80,472 KB
testcase_15 AC 85 ms
77,824 KB
testcase_16 AC 171 ms
109,924 KB
testcase_17 AC 180 ms
112,256 KB
testcase_18 AC 214 ms
125,324 KB
testcase_19 AC 223 ms
128,776 KB
testcase_20 AC 203 ms
120,020 KB
testcase_21 AC 279 ms
150,764 KB
testcase_22 AC 276 ms
150,028 KB
testcase_23 AC 275 ms
149,696 KB
testcase_24 AC 271 ms
149,752 KB
testcase_25 AC 277 ms
150,600 KB
testcase_26 AC 165 ms
154,412 KB
testcase_27 AC 285 ms
154,536 KB
testcase_28 AC 205 ms
122,188 KB
testcase_29 AC 76 ms
71,124 KB
testcase_30 AC 74 ms
71,320 KB
testcase_31 AC 272 ms
154,148 KB
testcase_32 AC 80 ms
76,048 KB
testcase_33 AC 78 ms
76,088 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=n*m-(m*(2*m*m+3*m-5)//6-c[a]*p-c[q])//a
  print(ans%(10**9+7))
0