結果

問題 No.800 四平方定理
ユーザー MayimgMayimg
提出日時 2019-03-17 22:19:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 538 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 207,200 KB
実行使用メモリ 61,180 KB
最終ジャッジ日時 2023-09-22 07:25:28
合計ジャッジ時間 23,628 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,380 KB
testcase_01 AC 18 ms
4,724 KB
testcase_02 AC 13 ms
4,376 KB
testcase_03 AC 14 ms
4,412 KB
testcase_04 AC 13 ms
4,380 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 21 ms
4,812 KB
testcase_07 AC 19 ms
4,420 KB
testcase_08 AC 17 ms
4,760 KB
testcase_09 AC 20 ms
4,524 KB
testcase_10 AC 1,444 ms
30,432 KB
testcase_11 AC 1,515 ms
33,688 KB
testcase_12 AC 1,573 ms
33,372 KB
testcase_13 AC 1,254 ms
31,800 KB
testcase_14 AC 1,347 ms
33,876 KB
testcase_15 AC 1,573 ms
33,668 KB
testcase_16 AC 1,329 ms
34,272 KB
testcase_17 AC 1,365 ms
34,136 KB
testcase_18 AC 1,722 ms
34,088 KB
testcase_19 AC 1,691 ms
34,060 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1,863 ms
34,008 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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