結果

問題 No.1593 Perfect Distance
ユーザー Tsukumowan
提出日時 2021-07-10 13:41:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 199,368 KB
最終ジャッジ日時 2025-01-22 23:59:32
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(){
    int64_t n;
    cin >> n;
    vector<int64_t> v(n, 1);
    set<int64_t> s;
    for(int64_t i = 1;i < n;i++){
         v[i] = i * i;
         s.insert(v[i]);
    }
    int64_t root = n * n;
    int ans = 0;
    for(int i = 1;i < n;i++){
        if(v[i] >= root) break;
        if(s.find(root - v[i]) != s.end()){
            ans++;
        }
    }
    cout << ans << endl;
}
0