結果

問題 No.800 四平方定理
ユーザー kyo1kyo1
提出日時 2020-06-18 21:52:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 199,452 KB
実行使用メモリ 42,268 KB
最終ジャッジ日時 2023-09-16 12:22:00
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
42,184 KB
testcase_01 AC 13 ms
42,264 KB
testcase_02 AC 12 ms
42,084 KB
testcase_03 AC 12 ms
42,128 KB
testcase_04 AC 12 ms
42,180 KB
testcase_05 AC 13 ms
42,260 KB
testcase_06 AC 13 ms
42,212 KB
testcase_07 AC 13 ms
42,136 KB
testcase_08 AC 13 ms
42,256 KB
testcase_09 AC 12 ms
42,268 KB
testcase_10 AC 28 ms
42,184 KB
testcase_11 AC 32 ms
42,144 KB
testcase_12 AC 31 ms
42,148 KB
testcase_13 AC 29 ms
42,128 KB
testcase_14 AC 30 ms
42,140 KB
testcase_15 AC 31 ms
42,140 KB
testcase_16 AC 31 ms
42,144 KB
testcase_17 AC 31 ms
42,188 KB
testcase_18 AC 33 ms
42,120 KB
testcase_19 AC 34 ms
42,156 KB
testcase_20 AC 13 ms
42,204 KB
testcase_21 AC 12 ms
42,188 KB
testcase_22 AC 34 ms
42,128 KB
testcase_23 AC 70 ms
42,192 KB
testcase_24 AC 67 ms
42,180 KB
testcase_25 AC 71 ms
42,180 KB
testcase_26 AC 12 ms
42,140 KB
testcase_27 AC 12 ms
42,148 KB
testcase_28 AC 62 ms
42,132 KB
testcase_29 AC 67 ms
42,084 KB
testcase_30 AC 67 ms
42,200 KB
testcase_31 AC 59 ms
42,148 KB
testcase_32 AC 68 ms
42,136 KB
権限があれば一括ダウンロードができます

ソースコード

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(10000000, 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