結果

問題 No.800 四平方定理
ユーザー MayimgMayimg
提出日時 2019-03-17 22:43:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 198,952 KB
実行使用メモリ 23,944 KB
最終ジャッジ日時 2023-09-22 08:46:37
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 15 ms
13,560 KB
testcase_11 AC 16 ms
13,588 KB
testcase_12 AC 16 ms
15,616 KB
testcase_13 AC 13 ms
11,588 KB
testcase_14 AC 15 ms
13,560 KB
testcase_15 AC 17 ms
15,692 KB
testcase_16 AC 15 ms
13,588 KB
testcase_17 AC 14 ms
13,588 KB
testcase_18 AC 18 ms
17,888 KB
testcase_19 AC 18 ms
17,680 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 18 ms
17,748 KB
testcase_23 AC 32 ms
23,944 KB
testcase_24 AC 25 ms
19,808 KB
testcase_25 AC 42 ms
23,860 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 31 ms
19,704 KB
testcase_29 AC 31 ms
21,836 KB
testcase_30 AC 36 ms
19,764 KB
testcase_31 AC 26 ms
19,780 KB
testcase_32 AC 33 ms
19,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int cnt[8000000] = {};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, d;
  cin >> n >> d;
  for (int w = 1; w <= n; w++) {
    for (int z = 1; z <= n; z++) {
      if (d + w * w - z * z < 0) continue;
      if (d + w * w - z * z > 2 * n * n) continue;
      cnt[d + w * w - z * z]++;
    }
  }
  long long ans = 0;
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      ans += cnt[x * x + y * y];
    }
  }
  cout << ans << endl;
  return 0;	
}
0