結果

問題 No.800 四平方定理
ユーザー MayimgMayimg
提出日時 2019-03-17 22:43:54
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 1,721 ms
使用メモリ 22,964 KB
最終ジャッジ日時 2023-02-11 10:00:10
合計ジャッジ時間 3,493 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,644 KB
testcase_01 AC 2 ms
3,828 KB
testcase_02 AC 2 ms
3,636 KB
testcase_03 AC 1 ms
3,620 KB
testcase_04 AC 1 ms
3,656 KB
testcase_05 AC 2 ms
3,740 KB
testcase_06 AC 1 ms
3,892 KB
testcase_07 AC 2 ms
3,796 KB
testcase_08 AC 2 ms
3,568 KB
testcase_09 AC 2 ms
3,844 KB
testcase_10 AC 15 ms
13,080 KB
testcase_11 AC 13 ms
13,028 KB
testcase_12 AC 15 ms
14,112 KB
testcase_13 AC 12 ms
11,488 KB
testcase_14 AC 12 ms
12,152 KB
testcase_15 AC 13 ms
14,240 KB
testcase_16 AC 12 ms
12,292 KB
testcase_17 AC 13 ms
12,240 KB
testcase_18 AC 15 ms
16,160 KB
testcase_19 AC 15 ms
16,252 KB
testcase_20 AC 1 ms
3,432 KB
testcase_21 AC 2 ms
3,524 KB
testcase_22 AC 15 ms
16,264 KB
testcase_23 AC 29 ms
22,908 KB
testcase_24 AC 23 ms
19,204 KB
testcase_25 AC 32 ms
22,964 KB
testcase_26 AC 2 ms
3,524 KB
testcase_27 AC 2 ms
3,452 KB
testcase_28 AC 22 ms
18,944 KB
testcase_29 AC 27 ms
21,036 KB
testcase_30 AC 24 ms
19,092 KB
testcase_31 AC 23 ms
17,852 KB
testcase_32 AC 23 ms
19,576 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