結果

問題 No.800 四平方定理
ユーザー umezoumezo
提出日時 2022-08-09 19:35:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 2,503 ms
コンパイル使用メモリ 200,980 KB
実行使用メモリ 34,280 KB
最終ジャッジ日時 2023-10-20 04:26:46
合計ジャッジ時間 4,086 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 4 ms
6,332 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
6,272 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 24 ms
20,668 KB
testcase_11 AC 28 ms
22,716 KB
testcase_12 AC 27 ms
22,716 KB
testcase_13 AC 24 ms
20,668 KB
testcase_14 AC 27 ms
22,716 KB
testcase_15 AC 30 ms
22,716 KB
testcase_16 AC 27 ms
22,716 KB
testcase_17 AC 28 ms
22,716 KB
testcase_18 AC 30 ms
22,716 KB
testcase_19 AC 31 ms
22,716 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 30 ms
22,716 KB
testcase_23 AC 77 ms
34,280 KB
testcase_24 AC 72 ms
34,280 KB
testcase_25 AC 78 ms
34,188 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 72 ms
34,132 KB
testcase_29 AC 77 ms
34,224 KB
testcase_30 AC 74 ms
34,164 KB
testcase_31 AC 64 ms
32,956 KB
testcase_32 AC 76 ms
34,280 KB
権限があれば一括ダウンロードができます

ソースコード

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