結果

問題 No.800 四平方定理
ユーザー umezo
提出日時 2022-08-09 19:35:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 1,787 ms
コンパイル使用メモリ 193,752 KB
最終ジャッジ日時 2025-01-30 19:46:49
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

int A[8000800];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,d;
  cin>>n>>d;
  
  ll ans=0;
  for(int x=1;x<=n;x++){
    int t=x*x;
    for(int y=1;y<=n;y++) A[t+y*y]++;
  }
  for(int z=1;z<=n;z++){
    int t=z*z;
    for(int w=1;w<=n;w++){
      int s=w*w+d-t;
      if(s>=0 && s<8000800) ans+=A[w*w+d-t];
    }
  }
  cout<<ans<<endl;
  
  return 0;
}
0