結果

問題 No.800 四平方定理
コンテスト
ユーザー Mayimg
提出日時 2019-03-17 22:19:11
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,516 ms
コンパイル使用メモリ 218,752 KB
実行使用メモリ 34,304 KB
最終ジャッジ日時 2026-06-07 08:09:09
合計ジャッジ時間 24,474 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 TLE * 3 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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