結果
| 問題 | No.1593 Perfect Distance | 
| コンテスト | |
| ユーザー |  startcpp | 
| 提出日時 | 2021-07-09 21:24:32 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 14 ms / 2,000 ms | 
| コード長 | 632 bytes | 
| コンパイル時間 | 699 ms | 
| コンパイル使用メモリ | 83,148 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-01 15:01:12 | 
| 合計ジャッジ時間 | 1,483 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
int n;
signed main() {
	cin >> n;
	
	int ans = 0;
	for (int x = 1; x < n; x++) {
		int y2 = n * n - x * x;
		int ng = -1, ok = n + 1, mid;
		while (ok - ng >= 2) {
			mid = (ng + ok) / 2;
			if (mid * mid >= y2) ok = mid;
			else ng = mid;
		}
		if (ok * ok == y2 && ok >= 1) {
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}
            
            
            
        