結果

問題 No.1593 Perfect Distance
ユーザー oooooba
提出日時 2021-08-12 21:51:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 1,335 ms
コンパイル使用メモリ 118,080 KB
最終ジャッジ日時 2025-01-23 17:48:19
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std; // NOLINT

int main() {
    int64_t n;
    cin >> n;
    unordered_set<int64_t> sqrts;
    for (int64_t i = 1; i * i < n * n; ++i) {
        sqrts.insert(i * i);
    }
    int32_t ans = 0;
    for (int64_t x = 1; x * x < n * n; ++x) {
        auto y2 = n * n - x * x;
        if (sqrts.find(y2) != sqrts.end())
            ++ans;
    }
    cout << ans << endl;
    return 0;
}
0