結果

問題 No.1918 Simple Math ?
ユーザー qib
提出日時 2022-11-10 16:23:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 333 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 69,956 KB
最終ジャッジ日時 2024-07-23 18:29:17
合計ジャッジ時間 12,604 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 TLE * 3 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

MOD = 10 ** 9 + 7

t = int(input())
for _ in range(t):
  a, n = map(int, input().split())

  ans = 0
  for x in range(1, int(math.sqrt(n * a)) + 1):
    lb = (x * x + a - 1) // a
    ub = min(n + 1, ((x + 1) * (x + 1) + a - 1) // a)
    if ub - lb <= 0:
      continue
    ans = (ans + (ub - lb) * x) % MOD

  print(ans)
0