結果

問題 No.800 四平方定理
ユーザー けーむけーむ
提出日時 2020-03-27 11:16:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,024 bytes
コンパイル時間 1,724 ms
コンパイル使用メモリ 166,160 KB
実行使用メモリ 65,484 KB
最終ジャッジ日時 2023-08-30 16:21:30
合計ジャッジ時間 5,527 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,500 KB
testcase_09 AC 2 ms
4,392 KB
testcase_10 AC 38 ms
34,084 KB
testcase_11 AC 42 ms
37,804 KB
testcase_12 AC 43 ms
37,380 KB
testcase_13 AC 39 ms
35,388 KB
testcase_14 AC 40 ms
37,700 KB
testcase_15 AC 44 ms
37,540 KB
testcase_16 AC 43 ms
38,040 KB
testcase_17 AC 45 ms
38,296 KB
testcase_18 AC 49 ms
38,064 KB
testcase_19 AC 48 ms
38,052 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 49 ms
38,132 KB
testcase_23 AC 100 ms
65,412 KB
testcase_24 AC 94 ms
65,364 KB
testcase_25 AC 99 ms
65,316 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 89 ms
65,076 KB
testcase_29 AC 95 ms
65,232 KB
testcase_30 AC 89 ms
65,256 KB
testcase_31 AC 80 ms
60,816 KB
testcase_32 AC 93 ms
65,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, d;
    cin >> n >> d;
    const ll MAX_V = 2 * n * n;
    vector<ll> dp(MAX_V + 1, 0);
    reps(i, 1, n + 1) {
        reps(j, 1, n + 1) {
            ll v = i * i + j * j;
            dp[v]++;
        }
    }
    ll ans = 0;
    reps(i, 1, n + 1) {
        reps(j, 1, n + 1) {
            ll v = i * i - j * j;
            ll a = d - v;
            if ((a < 0) || (a > MAX_V)) continue;
            ans += dp[a];
        }
    }
    cout << ans << endl;
    return 0;
}
0