結果

問題 No.800 四平方定理
ユーザー Akidai16Akidai16
提出日時 2021-05-09 20:40:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 889 bytes
コンパイル時間 4,835 ms
コンパイル使用メモリ 228,312 KB
実行使用メモリ 34,604 KB
最終ジャッジ日時 2023-10-19 05:09:56
合計ジャッジ時間 6,129 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 27 ms
18,780 KB
testcase_11 AC 30 ms
20,824 KB
testcase_12 AC 31 ms
20,560 KB
testcase_13 AC 25 ms
19,504 KB
testcase_14 AC 28 ms
20,824 KB
testcase_15 AC 31 ms
20,560 KB
testcase_16 AC 30 ms
20,824 KB
testcase_17 AC 29 ms
20,824 KB
testcase_18 AC 32 ms
20,824 KB
testcase_19 AC 33 ms
20,824 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 34 ms
20,824 KB
testcase_23 AC 73 ms
34,604 KB
testcase_24 AC 67 ms
34,604 KB
testcase_25 AC 77 ms
34,604 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 RE -
testcase_28 AC 71 ms
34,340 KB
testcase_29 AC 75 ms
34,604 KB
testcase_30 AC 69 ms
34,604 KB
testcase_31 AC 61 ms
32,296 KB
testcase_32 AC 70 ms
34,604 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(2 * N * N + 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