結果

問題 No.800 四平方定理
ユーザー risujirohrisujiroh
提出日時 2019-03-17 21:28:00
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 1,312 ms
使用メモリ 104,528 KB
最終ジャッジ日時 2023-02-11 04:08:51
合計ジャッジ時間 4,307 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,900 KB
testcase_01 AC 3 ms
4,912 KB
testcase_02 AC 2 ms
4,900 KB
testcase_03 AC 2 ms
4,904 KB
testcase_04 AC 2 ms
6,948 KB
testcase_05 AC 2 ms
4,904 KB
testcase_06 AC 3 ms
5,092 KB
testcase_07 AC 3 ms
5,544 KB
testcase_08 AC 4 ms
7,312 KB
testcase_09 AC 3 ms
4,932 KB
testcase_10 AC 35 ms
53,276 KB
testcase_11 AC 37 ms
57,176 KB
testcase_12 AC 39 ms
58,672 KB
testcase_13 AC 31 ms
51,688 KB
testcase_14 AC 33 ms
55,052 KB
testcase_15 AC 37 ms
58,936 KB
testcase_16 AC 34 ms
55,732 KB
testcase_17 AC 34 ms
55,808 KB
testcase_18 AC 41 ms
63,236 KB
testcase_19 AC 41 ms
63,536 KB
testcase_20 AC 1 ms
4,900 KB
testcase_21 AC 2 ms
4,900 KB
testcase_22 AC 43 ms
63,568 KB
testcase_23 AC 89 ms
104,528 KB
testcase_24 AC 75 ms
96,868 KB
testcase_25 AC 88 ms
104,232 KB
testcase_26 AC 1 ms
6,952 KB
testcase_27 AC 4 ms
10,768 KB
testcase_28 AC 75 ms
96,308 KB
testcase_29 AC 116 ms
100,452 KB
testcase_30 AC 132 ms
96,348 KB
testcase_31 AC 117 ms
89,960 KB
testcase_32 AC 134 ms
97,556 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