結果

問題 No.1918 Simple Math ?
ユーザー sotanishysotanishy
提出日時 2022-04-30 00:11:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 675 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 1,119 ms
コンパイル使用メモリ 86,668 KB
実行使用メモリ 77,004 KB
最終ジャッジ日時 2023-09-11 15:55:28
合計ジャッジ時間 11,990 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
76,140 KB
testcase_01 AC 83 ms
75,836 KB
testcase_02 AC 84 ms
76,216 KB
testcase_03 AC 82 ms
76,040 KB
testcase_04 AC 83 ms
76,144 KB
testcase_05 AC 84 ms
76,128 KB
testcase_06 AC 116 ms
76,036 KB
testcase_07 AC 139 ms
75,884 KB
testcase_08 AC 106 ms
76,056 KB
testcase_09 AC 92 ms
75,668 KB
testcase_10 AC 116 ms
76,216 KB
testcase_11 AC 78 ms
75,956 KB
testcase_12 AC 133 ms
76,020 KB
testcase_13 AC 115 ms
76,072 KB
testcase_14 AC 97 ms
76,000 KB
testcase_15 AC 87 ms
76,020 KB
testcase_16 AC 341 ms
76,724 KB
testcase_17 AC 329 ms
76,724 KB
testcase_18 AC 435 ms
76,804 KB
testcase_19 AC 462 ms
76,792 KB
testcase_20 AC 395 ms
76,936 KB
testcase_21 AC 657 ms
76,760 KB
testcase_22 AC 655 ms
77,004 KB
testcase_23 AC 649 ms
76,612 KB
testcase_24 AC 649 ms
76,772 KB
testcase_25 AC 657 ms
76,808 KB
testcase_26 AC 459 ms
76,760 KB
testcase_27 AC 675 ms
76,788 KB
testcase_28 AC 284 ms
76,152 KB
testcase_29 AC 72 ms
71,244 KB
testcase_30 AC 72 ms
71,580 KB
testcase_31 AC 655 ms
76,740 KB
testcase_32 AC 76 ms
76,012 KB
testcase_33 AC 76 ms
76,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod = 10**9+7
T = int(input())
for _ in range(T):
    a, N = map(int, input().split())
    M = int((a*N)**0.5)
    ans = 0
    if (M+1)**2 <= a*N:
        M += 1
    for r in range(a):
        m = (M-r)//a
        ans += a*m*(m+1)*(2*m+1)//6+m*(m+1)*r + (r**2-1)//a*(m+1)
    ans = (N*M - ans - 1) % mod
    print(ans)
0