結果

問題 No.800 四平方定理
ユーザー kyo1kyo1
提出日時 2020-06-18 21:51:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 502 bytes
コンパイル時間 1,985 ms
コンパイル使用メモリ 201,436 KB
実行使用メモリ 26,872 KB
最終ジャッジ日時 2023-09-16 12:21:55
合計ジャッジ時間 6,216 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
26,584 KB
testcase_01 AC 8 ms
26,556 KB
testcase_02 AC 9 ms
26,384 KB
testcase_03 AC 8 ms
26,516 KB
testcase_04 AC 9 ms
26,324 KB
testcase_05 AC 9 ms
26,320 KB
testcase_06 AC 9 ms
26,304 KB
testcase_07 AC 8 ms
26,364 KB
testcase_08 AC 8 ms
26,504 KB
testcase_09 AC 8 ms
26,376 KB
testcase_10 AC 22 ms
26,620 KB
testcase_11 AC 27 ms
26,432 KB
testcase_12 AC 27 ms
26,380 KB
testcase_13 AC 24 ms
26,296 KB
testcase_14 AC 25 ms
26,424 KB
testcase_15 AC 29 ms
26,520 KB
testcase_16 AC 26 ms
26,528 KB
testcase_17 AC 26 ms
26,628 KB
testcase_18 AC 30 ms
26,356 KB
testcase_19 AC 30 ms
26,332 KB
testcase_20 AC 8 ms
26,436 KB
testcase_21 AC 8 ms
26,380 KB
testcase_22 AC 28 ms
26,548 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 8 ms
26,364 KB
testcase_27 AC 7 ms
26,608 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, D;
  cin >> N >> D;
  vector<int> A(6000000, 0);
  unordered_map<int, int> mp;
  for (int x = 1; x < N + 1; x++) {
    for (int y = 1; y < N + 1; y++) {
      A[x * x + y * y]++;
    }
  }
  int res = 0;
  for (int z = 1; z < N + 1; z++) {
    for (int w = 1; w < N + 1; w++) {
      if (D + w * w - z * z > 0) res += A[D + w * w - z * z];
    }
  }
  cout << res << '\n';
  return 0;
}
0