結果

問題 No.1593 Perfect Distance
ユーザー monkukuimonkukui
提出日時 2021-07-09 21:29:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 354 ms / 2,000 ms
コード長 1,864 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 119,376 KB
実行使用メモリ 50,544 KB
最終ジャッジ日時 2023-09-14 07:50:59
合計ジャッジ時間 9,052 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 330 ms
50,400 KB
testcase_01 AC 328 ms
50,228 KB
testcase_02 AC 330 ms
50,212 KB
testcase_03 AC 329 ms
50,220 KB
testcase_04 AC 327 ms
50,216 KB
testcase_05 AC 326 ms
50,320 KB
testcase_06 AC 326 ms
50,228 KB
testcase_07 AC 329 ms
50,264 KB
testcase_08 AC 331 ms
50,236 KB
testcase_09 AC 332 ms
50,264 KB
testcase_10 AC 331 ms
50,208 KB
testcase_11 AC 333 ms
50,264 KB
testcase_12 AC 338 ms
50,544 KB
testcase_13 AC 343 ms
50,216 KB
testcase_14 AC 345 ms
50,316 KB
testcase_15 AC 350 ms
50,264 KB
testcase_16 AC 354 ms
50,216 KB
testcase_17 AC 330 ms
50,216 KB
testcase_18 AC 329 ms
50,212 KB
testcase_19 AC 327 ms
50,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>
#include <cstddef>
#include <type_traits>
#include <vector>

using namespace std;
const long long int INF = numeric_limits<long long int>::max() / 4;
const int inf = numeric_limits<int>::max() / 4;
const long long int MOD1000000007 = 1000000007;
const long long int MOD998244353 = 998244353;
const double MATH_PI = 3.1415926535897932;

template<typename T1, typename T2>
inline void chmin(T1 &a, const T2 &b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, const T2 &b) { if (a < b) a = b; }

#define lint long long int
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define VI vector<int>
#define VLL vector<long long>
#define VC vector<char>
#define VB vector<bool>
#define PI pair<int, int>
#define PLL pair<long long, long long>
#define VPI vector<pair<int, int>>
#define VPLL vector<pair<long long, long long>>
#define VVI vector<vector<int>>
#define VVPI vecor<vector<pair<int, int>>>
#define VVPILL vector<vector<pair<int, long long>>>

#define SUM(v) accumulate(ALL(v), 0LL)
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))

int main() {

    set<lint> st;
    for (lint i = 1; i <= 1000000; i++) {
        st.insert(i * i);
    }
    lint n;
    cin >> n;
    lint ans = 0;
    for (lint x = 1; x * x <= n * n; x++) {
        lint yy = n * n - x * x;
        if (st.count(yy)) ans++;
    }
    cout << ans << endl;
    return 0;
}
0