結果

問題 No.800 四平方定理
ユーザー t33ft33f
提出日時 2019-03-17 22:46:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 535 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 72,068 KB
実行使用メモリ 23,644 KB
最終ジャッジ日時 2023-09-22 08:54:25
合計ジャッジ時間 5,025 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
22,604 KB
testcase_01 AC 7 ms
22,588 KB
testcase_02 AC 7 ms
22,600 KB
testcase_03 AC 7 ms
22,492 KB
testcase_04 AC 7 ms
22,592 KB
testcase_05 AC 7 ms
22,500 KB
testcase_06 AC 8 ms
22,520 KB
testcase_07 AC 7 ms
22,572 KB
testcase_08 AC 7 ms
22,500 KB
testcase_09 AC 7 ms
22,504 KB
testcase_10 AC 16 ms
22,644 KB
testcase_11 AC 18 ms
22,512 KB
testcase_12 AC 19 ms
22,576 KB
testcase_13 AC 18 ms
22,572 KB
testcase_14 AC 21 ms
22,568 KB
testcase_15 AC 20 ms
22,576 KB
testcase_16 AC 20 ms
22,492 KB
testcase_17 AC 18 ms
22,492 KB
testcase_18 AC 18 ms
22,588 KB
testcase_19 AC 18 ms
22,424 KB
testcase_20 AC 7 ms
22,548 KB
testcase_21 AC 7 ms
22,596 KB
testcase_22 AC 20 ms
22,616 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 7 ms
22,516 KB
testcase_27 AC 7 ms
22,624 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n, D; cin >> n >> D;
    constexpr int N = 5'000'001;
    vector<int> div(N, 0);
    for (int d = 1; d <= n; d++)
        for (int m = d+2; m <= 2*n - d && m * d < N; m += 2)
            div[m*d]++;

    long long ans = 0;
    for (int x = 1; x <= n; x++)
        for (int y = 1; y <= n; y++) {
            int v = abs(x*x + y*y - D);
            if (v == 0) ans += n;
            else ans += div[v];
        }
    cout << ans << endl;
}
0