結果

問題 No.1593 Perfect Distance
ユーザー OmameBeansOmameBeans
提出日時 2021-07-16 01:15:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 173,684 KB
実行使用メモリ 28,408 KB
最終ジャッジ日時 2023-09-18 12:07:46
合計ジャッジ時間 4,384 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
15,892 KB
testcase_01 AC 60 ms
15,896 KB
testcase_02 AC 60 ms
15,804 KB
testcase_03 AC 60 ms
15,812 KB
testcase_04 AC 60 ms
16,076 KB
testcase_05 AC 61 ms
15,952 KB
testcase_06 AC 61 ms
15,808 KB
testcase_07 AC 61 ms
16,036 KB
testcase_08 AC 61 ms
15,872 KB
testcase_09 AC 63 ms
16,468 KB
testcase_10 AC 69 ms
17,800 KB
testcase_11 AC 73 ms
18,552 KB
testcase_12 AC 82 ms
20,680 KB
testcase_13 AC 84 ms
20,848 KB
testcase_14 AC 88 ms
21,764 KB
testcase_15 AC 102 ms
24,432 KB
testcase_16 AC 123 ms
28,408 KB
testcase_17 AC 60 ms
15,860 KB
testcase_18 AC 61 ms
15,804 KB
testcase_19 AC 60 ms
16,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

int main() {
    ll N; cin >> N;
    ll ans = 0;
    map<ll,ll> ex;
    for(ll i = 1; i <= 200000; i++) {
        ex[i*i]++;
    }

    for(ll i = 1; i <= 200000; i++) {
        if(N*N - i*i <= 0) continue;
        ll j = N*N - i*i;
        if(ex[j]) ans++;
    }
    cout << ans << endl;
    return 0;
}
0