結果

問題 No.1593 Perfect Distance
ユーザー kobakoba_issakobakoba_issa
提出日時 2021-07-09 22:17:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 198,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 09:31:11
合計ジャッジ時間 3,024 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
0