結果

問題 No.800 四平方定理
ユーザー risujirohrisujiroh
提出日時 2019-03-17 21:28:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 1,498 ms
コンパイル使用メモリ 167,424 KB
実行使用メモリ 104,512 KB
最終ジャッジ日時 2023-09-22 03:44:43
合計ジャッジ時間 4,397 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,824 KB
testcase_02 AC 3 ms
4,408 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 4 ms
4,408 KB
testcase_06 AC 4 ms
5,156 KB
testcase_07 AC 4 ms
5,352 KB
testcase_08 AC 5 ms
7,308 KB
testcase_09 AC 4 ms
4,900 KB
testcase_10 AC 51 ms
53,216 KB
testcase_11 AC 57 ms
57,120 KB
testcase_12 AC 59 ms
58,560 KB
testcase_13 AC 51 ms
51,716 KB
testcase_14 AC 53 ms
55,264 KB
testcase_15 AC 58 ms
58,884 KB
testcase_16 AC 53 ms
55,728 KB
testcase_17 AC 56 ms
55,804 KB
testcase_18 AC 66 ms
63,588 KB
testcase_19 AC 64 ms
63,372 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 66 ms
63,508 KB
testcase_23 AC 128 ms
104,512 KB
testcase_24 AC 107 ms
97,076 KB
testcase_25 AC 124 ms
104,404 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 5 ms
10,800 KB
testcase_28 AC 109 ms
96,476 KB
testcase_29 AC 115 ms
100,520 KB
testcase_30 AC 107 ms
96,404 KB
testcase_31 AC 104 ms
89,796 KB
testcase_32 AC 111 ms
97,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, d; cin >> n >> d;
  V<lint> l(2 * n * n + 1);
  for (int x = 1; x <= n; ++x) for (int y = 1; y <= n; ++y) {
    ++l[x * x + y * y];
  }
  V<lint> r(d + n * n);
  for (int w = 1; w <= n; ++w) for (int z = 1; z <= n; ++z) {
    lint t = d + w * w - z * z;
    if (t >= 0) ++r[t];
  }
  lint res = 0;
  for (int i = 0; i < min(l.size(), r.size()); ++i) {
    res += l[i] * r[i];
  }
  cout << res << '\n';
}
0