結果

問題 No.1593 Perfect Distance
ユーザー Joe75792433Joe75792433
提出日時 2021-07-09 21:26:45
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,801 bytes
コンパイル時間 4,745 ms
使用メモリ 12,516 KB
最終ジャッジ日時 2023-02-01 22:04:11
合計ジャッジ時間 5,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,496 KB
testcase_01 AC 2 ms
3,584 KB
testcase_02 AC 1 ms
3,432 KB
testcase_03 AC 2 ms
3,500 KB
testcase_04 AC 1 ms
3,444 KB
testcase_05 AC 1 ms
3,536 KB
testcase_06 AC 1 ms
3,496 KB
testcase_07 AC 1 ms
3,440 KB
testcase_08 AC 2 ms
3,476 KB
testcase_09 AC 3 ms
3,720 KB
testcase_10 AC 6 ms
4,304 KB
testcase_11 AC 10 ms
5,564 KB
testcase_12 AC 16 ms
6,036 KB
testcase_13 AC 16 ms
6,176 KB
testcase_14 AC 21 ms
7,764 KB
testcase_15 AC 31 ms
8,884 KB
testcase_16 AC 56 ms
12,516 KB
testcase_17 AC 2 ms
3,556 KB
testcase_18 AC 2 ms
3,436 KB
testcase_19 AC 1 ms
3,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef _DEBUG
    #include <atcoder/all.h>
    #define debug(x) std::cout << #x << ": " << x << std::endl
#else
    #include <bits/stdc++.h>
    #include <atcoder/all>
    //#pragma GCC target("arch=skylake-avx512")
    #pragma GCC optimize("O3")
    #pragma GCC optimize("unroll-loops")
    #define debug(x)
#endif
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(...) _overloadrep(__VA_ARGS__, _rep4, _rep3, _rep2)(__VA_ARGS__)
#define _overloadrep(_1, _2, _3, _4, _repn, ...) _repn
#define _rep2(i, n) _rep4(i, 0, n, 1)
#define _rep3(i, a, b) _rep4(i, a, b, 1)
#define _rep4(i, a, b, s) for (auto i = (a); i < (b); i += (s))
#define repr(i, a, b) for (auto i = (b)-1; i >= (a); --i)
#define all(x) (x).begin(), (x).end()
#define siz(x) int((x).size())
template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) { if (a < b) { a = b; return true; } return false; }
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) { if (a > b) { a = b; return true; } return false; }
constexpr char enl = '\n';
constexpr int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr long double eps = 1e-10;
constexpr int INF = 1010000000;  // 1e9
constexpr ll llINF = 3010000000000000000LL;  // 3e18
constexpr ll MOD = 1000000007LL;
//constexpr ll MOD = 998244353LL;
using mint = static_modint<MOD>;

void Main([[maybe_unused]] int testcase_i) {
    ll n; cin >> n;
    n *= n;
    unordered_set<ll> s;
    for (ll i = 1; i * i < n; ++i) {
        s.insert(i*i);
    }
    ll ans = 0;
    for (auto x : s) if (s.count(n-x)) ++ans;
    cout << ans << enl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;
    rep(i, t) Main(i);
}
0