結果

問題 No.800 四平方定理
ユーザー Akidai16Akidai16
提出日時 2021-05-09 20:41:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 3,968 ms
コンパイル使用メモリ 229,124 KB
実行使用メモリ 34,556 KB
最終ジャッジ日時 2023-10-19 05:11:46
合計ジャッジ時間 6,302 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
34,556 KB
testcase_01 AC 11 ms
34,556 KB
testcase_02 AC 12 ms
34,556 KB
testcase_03 AC 11 ms
34,556 KB
testcase_04 AC 11 ms
34,556 KB
testcase_05 AC 11 ms
34,556 KB
testcase_06 AC 11 ms
34,556 KB
testcase_07 AC 12 ms
34,556 KB
testcase_08 AC 12 ms
34,556 KB
testcase_09 AC 11 ms
34,556 KB
testcase_10 AC 31 ms
34,556 KB
testcase_11 AC 35 ms
34,556 KB
testcase_12 AC 35 ms
34,556 KB
testcase_13 AC 32 ms
34,556 KB
testcase_14 AC 34 ms
34,556 KB
testcase_15 AC 35 ms
34,556 KB
testcase_16 AC 34 ms
34,556 KB
testcase_17 AC 34 ms
34,556 KB
testcase_18 AC 38 ms
34,556 KB
testcase_19 AC 36 ms
34,556 KB
testcase_20 AC 11 ms
34,556 KB
testcase_21 AC 11 ms
34,556 KB
testcase_22 AC 38 ms
34,556 KB
testcase_23 AC 77 ms
34,556 KB
testcase_24 AC 71 ms
34,556 KB
testcase_25 AC 74 ms
34,556 KB
testcase_26 AC 11 ms
34,556 KB
testcase_27 AC 11 ms
34,556 KB
testcase_28 AC 71 ms
34,556 KB
testcase_29 AC 71 ms
34,556 KB
testcase_30 AC 72 ms
34,556 KB
testcase_31 AC 62 ms
34,556 KB
testcase_32 AC 69 ms
34,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int N, D;
vi x2y2;

void solve() {
    x2y2.resize(2000 * 2000 * 2 + 1);
    REP(x, 1, N + 1) {
        REP(y, 1, N + 1) {
            int total = x * x + y * y;
            x2y2[total]++;
        }
    }
    long ans = 0;
    REP(w, 1, N + 1) {
        REP(z, 1, N + 1) {
            int search = D + w * w - z * z; 
            if(search <= 0) continue;
            ans += x2y2[search];
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> D;
    solve();
}
0