結果

問題 No.3360 平方根の整数倍の整数部分
コンテスト
ユーザー Kude
提出日時 2025-11-14 21:55:20
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 64 ms / 2,000 ms
+ 249µs
コード長 379 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 233 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 79,232 KB
最終ジャッジ日時 2026-07-16 15:01:57
合計ジャッジ時間 4,409 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import isqrt
n, m = map(int, input().split())
if n == 1:
    print('NaN')
    exit()
def f(x):
    # t*sqrt(n) - 1 < x
    # t^2 < (x+1)^2 / n
    tmx = isqrt(max(0, ((x+1) ** 2 + n - 1) // n - 1))
    return x - tmx >= m

l = 0
r = 1
while not f(r):
    l = r
    r *= 2
while r - l > 1:
    c = (l + r) // 2
    if f(c):
        r = c
    else:
        l = c
print(r)
0