結果

問題 No.2392 二平方和
ユーザー uip-klehuip-kleh
提出日時 2023-07-31 15:41:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 1,769 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 172,476 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 15:43:08
合計ジャッジ時間 3,246 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 59 ms
6,940 KB
testcase_21 AC 222 ms
6,940 KB
testcase_22 AC 87 ms
6,944 KB
testcase_23 AC 35 ms
6,944 KB
testcase_24 AC 150 ms
6,940 KB
testcase_25 AC 116 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define nrep(i, n) for(ll i = 1; i < ll(n + 1); i++)
#define rrep(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define SIZE 2e5
#define INF 2e18
constexpr long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef vector<int> iv;
typedef vector<ll> lv;
typedef vector<bool> bv;
typedef pair<ll, ll> ip;
typedef vector<ip> pv;
typedef vector<iv> ivv;
typedef set<int> ist;
typedef set<ll> lst;
typedef map<int, int> imp;
typedef map<ll, ll> lmp;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

ll digsum(ll n) {
    ll res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

ll pow(ll x, ll n) {
    ll ans = 1;
    while (n) {
        if (n % 2) ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}

map<ll, ll> numeric_component(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; i++) {
        if (N % i != 0) continue;
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N]++;
    return res;
}

iv dx = {-1, 0, 1, 0};
iv dy = {0, -1, 0, 1};

struct edge {
    int from, to, length;
};

void print(iv &a) {
    for (auto v : a) cout << v << ' ';
    cout << endl;
}

int main() {
    int p; cin >> p;
    for(int i=1; i*i<p; i++){
        int j = p - i * i;
        map<ll, ll> comp = numeric_component((ll)j);
        bool is_square = true;
        for(auto iter: comp){
            if(iter.second % 2 == 1) is_square = false;
        }
        if(is_square) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}
0