結果

問題 No.800 四平方定理
ユーザー granddaifukugranddaifuku
提出日時 2020-04-25 17:41:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,099 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 165,576 KB
実行使用メモリ 34,428 KB
最終ジャッジ日時 2023-08-07 07:20:35
合計ジャッジ時間 4,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
34,308 KB
testcase_01 AC 12 ms
34,368 KB
testcase_02 AC 11 ms
34,304 KB
testcase_03 AC 10 ms
34,304 KB
testcase_04 AC 12 ms
34,372 KB
testcase_05 AC 11 ms
34,244 KB
testcase_06 AC 11 ms
34,308 KB
testcase_07 AC 12 ms
34,364 KB
testcase_08 AC 11 ms
34,368 KB
testcase_09 AC 12 ms
34,344 KB
testcase_10 AC 27 ms
34,404 KB
testcase_11 WA -
testcase_12 AC 29 ms
34,336 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 32 ms
34,356 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 29 ms
34,340 KB
testcase_19 AC 32 ms
34,328 KB
testcase_20 AC 11 ms
34,392 KB
testcase_21 AC 11 ms
34,368 KB
testcase_22 AC 30 ms
34,320 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 11 ms
34,340 KB
testcase_27 AC 11 ms
34,300 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int N = 4000001;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, d;
    cin >> n >> d;
    int res = 0;
    vector<int> plus(N), minus(N);
    FOR (i, 1, n + 1) {
        FOR (j, 1, n + 1) {
            int x = i * i - j * j;
            if (x >= 0) {
                plus[x]++;
            } else {
                x = abs(x);
                minus[x]++;
            }
        }
    }
    FOR (i, 1, n + 1) {
        FOR (j, 1, n + 1) {
            int tmp = i * i + j * j;
            int rest = d - tmp;
            if (rest >= 0) {
                res += plus[rest];
            } else {
                rest = abs(rest);
                res += minus[rest];
            }
        }
    }
    cout << res << endl;
    
    return 0;
}
0