結果

問題 No.800 四平方定理
ユーザー ninoinuininoinui
提出日時 2020-07-18 10:16:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 199,920 KB
実行使用メモリ 38,364 KB
最終ジャッジ日時 2023-08-20 17:09:47
合計ジャッジ時間 3,909 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,824 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 18 ms
20,436 KB
testcase_11 AC 19 ms
21,796 KB
testcase_12 AC 20 ms
22,212 KB
testcase_13 AC 16 ms
19,180 KB
testcase_14 AC 18 ms
20,432 KB
testcase_15 AC 20 ms
22,420 KB
testcase_16 AC 18 ms
20,628 KB
testcase_17 AC 20 ms
20,672 KB
testcase_18 AC 23 ms
24,436 KB
testcase_19 AC 23 ms
24,580 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 24 ms
24,664 KB
testcase_23 AC 54 ms
38,148 KB
testcase_24 AC 46 ms
34,376 KB
testcase_25 AC 52 ms
38,364 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 3 ms
6,976 KB
testcase_28 AC 46 ms
34,112 KB
testcase_29 AC 48 ms
36,392 KB
testcase_30 AC 46 ms
34,120 KB
testcase_31 AC 41 ms
31,908 KB
testcase_32 AC 46 ms
34,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, D;
  cin >> N >> D;
  vector<int> V(N * N * 2 + D + 1);
  for (int x = 1; x <= N; x++) {
    for (int y = 1; y <= N; y++) V.at(x * x + y * y)++;
  }
  int ans = 0;
  for (int w = 1; w <= N; w++) {
    for (int z = 1; z <= N; z++) {
      int tmp = w * w - z * z + D;
      if (tmp > 0) ans += V.at(tmp);
    }
  }
  cout << ans << "\n";
}
0