結果

問題 No.800 四平方定理
ユーザー GrayCoderGrayCoder
提出日時 2019-03-17 22:52:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 671 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 164,432 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 09:09:14
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
4,376 KB
testcase_01 AC 39 ms
4,380 KB
testcase_02 AC 23 ms
4,376 KB
testcase_03 AC 27 ms
4,376 KB
testcase_04 AC 24 ms
4,380 KB
testcase_05 AC 29 ms
4,376 KB
testcase_06 AC 47 ms
4,376 KB
testcase_07 AC 29 ms
4,376 KB
testcase_08 AC 33 ms
4,380 KB
testcase_09 AC 39 ms
4,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  long N, D;
  cin >> N >> D;

  long long w, x, y, z, n, ans;
  ans = 0;
  for (x=1; x<=N; x++) {
    for (y=1; y<=N; y++) {
      for (z=1; z<=N; z++) {
        n = x * x + y * y + z * z;
        if (n > D) {
          w = sqrt(n - D);
          if (w > N) break;
          if (n - w * w == D) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
0