結果
| 問題 | No.1593 Perfect Distance | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-10 01:39:42 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 16 ms / 2,000 ms | 
| コード長 | 564 bytes | 
| コンパイル時間 | 1,794 ms | 
| コンパイル使用メモリ | 165,836 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-01 20:34:10 | 
| 合計ジャッジ時間 | 2,482 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    
    int ans = 0;
    for(int i=1; i<n; i++){
      //cout << i << endl;
        int low=0, up = n;
        while(up-low>1){
          //cout << low << " < " << up << endl;
            int mid = (up+low)/2;
            if((ll)mid*mid>(ll)n*n-(ll)i*i) up = mid;
            else low = mid;
        }
        //cout << low << ' ' << i << ' ' << (ll) low*low+i*i << endl;
        if((ll)low*low+(ll)i*i == (ll)n*n) ans ++;
    }
    cout << ans << endl;
}
            
            
            
        