結果

問題 No.800 四平方定理
コンテスト
ユーザー やむなく
提出日時 2019-03-17 21:30:21
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 578 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,191 ms
コンパイル使用メモリ 188,500 KB
実行使用メモリ 67,328 KB
最終ジャッジ日時 2026-03-29 11:34:59
合計ジャッジ時間 21,586 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,d;
  cin >> n >> d;
  map<int,int> mp;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(i*i-j*j+d>=2) mp[i*i-j*j+d]++;
    }
  }
  LL ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      auto itr=mp.find(i*i+j*j);
      if(itr!=mp.end()) ans+=itr->second;
    }
  }
  cout << ans << endl;
  return 0;
}
0