結果
| 問題 | No.1593 Perfect Distance | 
| コンテスト | |
| ユーザー |  kobakoba_issa | 
| 提出日時 | 2021-07-09 22:17:01 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 780 bytes | 
| コンパイル時間 | 2,291 ms | 
| コンパイル使用メモリ | 193,224 KB | 
| 最終ジャッジ日時 | 2025-01-22 22:01:53 | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<60)-1;
#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)(a.size())
template<class T> 
bool chmax(T &a, T b) {if (a < b) {a = b;return true;}else return false;}
template<class T> 
bool chmin(T &a, T b) {if (a > b) {a = b;return true;}else return false;}
ll sqr(ll x){
	ll r=sqrt(x)-1;
	while((r+1)*(r+1)<=x)r++;
	return r;
}
//コーナーケースに気をつけろ!
int main() {
    ll n, ans = 0;   cin >> n;
    for (ll x = 1; x < n; x++) {
        ll y = sqr(n*n-x*x);
        if (y*y + x*x == n*n)   ans++;
    }
    cout << ans << endl;
    return 0;   
}
//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;
            
            
            
        