結果

問題 No.1593 Perfect Distance
ユーザー ki_ato_moki_ato_mo
提出日時 2021-07-10 18:22:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 89,924 KB
最終ジャッジ日時 2023-09-14 19:48:05
合計ジャッジ時間 3,341 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,340 KB
testcase_01 AC 70 ms
71,332 KB
testcase_02 AC 70 ms
71,140 KB
testcase_03 AC 68 ms
71,284 KB
testcase_04 AC 73 ms
71,296 KB
testcase_05 AC 68 ms
71,232 KB
testcase_06 AC 69 ms
71,288 KB
testcase_07 AC 78 ms
75,144 KB
testcase_08 AC 80 ms
75,380 KB
testcase_09 AC 102 ms
77,304 KB
testcase_10 AC 104 ms
77,608 KB
testcase_11 AC 117 ms
78,908 KB
testcase_12 AC 135 ms
81,444 KB
testcase_13 AC 137 ms
81,512 KB
testcase_14 AC 145 ms
82,448 KB
testcase_15 AC 163 ms
85,732 KB
testcase_16 AC 194 ms
89,924 KB
testcase_17 AC 71 ms
71,232 KB
testcase_18 AC 71 ms
71,272 KB
testcase_19 AC 71 ms
71,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
n = int(input())
kai = []
if n == 1:
    print(0)
else:
    for i in range(1, n):
        kai.append(i ** 2)
    ans = 0
    for i in range(1, n):
        if bisect_left(kai, n ** 2 - i ** 2) == len(kai):
            continue
        if kai[bisect_left(kai, n ** 2 - i ** 2)] == n ** 2 - i ** 2:
            ans += 1
    print(ans)
0