結果
| 問題 | No.1593 Perfect Distance | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-09 21:28:14 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 12 ms / 2,000 ms | 
| コード長 | 721 bytes | 
| コンパイル時間 | 3,649 ms | 
| コンパイル使用メモリ | 229,288 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-01 15:11:55 | 
| 合計ジャッジ時間 | 4,411 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#include<bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>
#define pll pair<ll,ll>
#define count __builtin_popcountll
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
const ll mod=1000000007;//998244353;
const ll inf=1000000000000000000;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};
int main(){
  cout << fixed << setprecision(15);
  ll n;
  cin >> n;
  ll ans=0;
  vec a(n+3);
  for(ll i=1;i<n+3;i++){
    a[i]=i*i;
  }
  for(ll i=1;i<n;i++){
    ll y=n*n-i*i;
    if(*lower_bound(a.begin(),a.end(),y)==y)ans++;
  }
  cout << ans << endl;
  return 0;
}
            
            
            
        