結果

問題 No.781 円周上の格子点の数え上げ
ユーザー shotoyooshotoyoo
提出日時 2021-05-25 23:35:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 216,832 KB
最終ジャッジ日時 2024-04-22 15:14:29
合計ジャッジ時間 4,117 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,480 KB
testcase_01 AC 39 ms
52,224 KB
testcase_02 AC 48 ms
52,352 KB
testcase_03 AC 39 ms
52,480 KB
testcase_04 AC 39 ms
52,224 KB
testcase_05 AC 39 ms
52,224 KB
testcase_06 AC 45 ms
60,032 KB
testcase_07 AC 46 ms
60,288 KB
testcase_08 AC 275 ms
137,984 KB
testcase_09 AC 273 ms
138,368 KB
testcase_10 AC 44 ms
59,008 KB
testcase_11 AC 46 ms
60,288 KB
testcase_12 AC 318 ms
181,376 KB
testcase_13 AC 360 ms
216,832 KB
testcase_14 AC 54 ms
64,896 KB
testcase_15 AC 44 ms
58,752 KB
testcase_16 AC 45 ms
58,752 KB
testcase_17 AC 225 ms
152,960 KB
testcase_18 AC 172 ms
106,112 KB
testcase_19 AC 171 ms
107,904 KB
testcase_20 AC 173 ms
107,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

x,y = list(map(int, input().split()))
eps = 10**-7
def isqrt(n):
    """x*x<=nなる最大のx
    """
    x,y = n, (n+1)//2
    while y<x:
        x,y = y, (y + n//y) // 2
    return x
def sub(x):
    ans = 0
    for v in range(x):
        vv = x - v*v
        if vv<=0:
            break
        if (int((vv**0.5)+eps)**2 - vv) == 0:
            ans += 4
#             print(v,vv)
    return ans
vals = [0]*(y+1)
for v in range(4000):
    if v*v>=y:
        break
    v2 = v*v
    for u in range(4000):
        u2 = u*u
        if v2 + u2>y:
            break
        vals[v2+u2] += 4
#         if v2+u2==25:
#             print(v,u)
ans = max(vals[x:])
print(ans)
0