結果
| 問題 | No.1593 Perfect Distance | 
| コンテスト | |
| ユーザー |  ikashoppin | 
| 提出日時 | 2021-07-09 21:36:26 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 150 ms / 2,000 ms | 
| コード長 | 796 bytes | 
| コンパイル時間 | 2,228 ms | 
| コンパイル使用メモリ | 198,724 KB | 
| 最終ジャッジ日時 | 2025-01-22 21:06:56 | 
| ジャッジサーバーID (参考情報) | judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
ostream &operator<<(ostream &os, const vector<T> &x){
    os << "{";
    for(size_t i = 0; i < x.size(); i++){
        if(i < x.size()-1) os << x[i] << ", ";
        else os << x[i];
    }
    os << "}";
    return os;
}
int main(void){
    lli n;
    cin >> n;
    n*=n;
    unordered_map<lli, bool> f;
    for(lli y = 1; y*y <= n; y++){
        f[y*y] = true;
    }
    lli ans = 0;
    for(lli x = 1; x*x <= n; x++){
        if(f[n-x*x]) ans++;
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        