結果

問題 No.1593 Perfect Distance
ユーザー naskyanaskya
提出日時 2021-07-09 23:50:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 69,148 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-14 11:17:28
合計ジャッジ時間 4,320 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,624 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

long long sqrtll(long long v) {
    long long ok = 0, ng = 1'000'000'000;
    
    while (ng - ok > 1) {
        const long long mid = ok + (ng - ok) / 2;
        (mid * mid <= v ? ok : ng) = mid;
    }

    return ok;
}

int main() {
    long long N;
    std::cin >> N;
    N *= N;

    long long res = 0LL;

    for (long long x = 1; x < N; ++x) {
        const long long y = sqrtll(N - x * x);
        res += (x * x + y * y == N);
    }

    std::cout << res << '\n';
}
0