結果

問題 No.800 四平方定理
ユーザー monnumonnu
提出日時 2020-09-29 22:23:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 164,964 KB
実行使用メモリ 34,592 KB
最終ジャッジ日時 2023-09-17 20:27:32
合計ジャッジ時間 3,470 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
34,336 KB
testcase_01 AC 11 ms
34,212 KB
testcase_02 AC 11 ms
34,252 KB
testcase_03 AC 12 ms
34,320 KB
testcase_04 AC 11 ms
34,560 KB
testcase_05 AC 11 ms
34,308 KB
testcase_06 AC 11 ms
34,284 KB
testcase_07 AC 11 ms
34,320 KB
testcase_08 AC 10 ms
34,240 KB
testcase_09 AC 11 ms
34,324 KB
testcase_10 AC 22 ms
34,304 KB
testcase_11 AC 26 ms
34,308 KB
testcase_12 AC 25 ms
34,256 KB
testcase_13 AC 23 ms
34,300 KB
testcase_14 AC 24 ms
34,336 KB
testcase_15 AC 26 ms
34,496 KB
testcase_16 AC 25 ms
34,256 KB
testcase_17 AC 24 ms
34,300 KB
testcase_18 AC 27 ms
34,384 KB
testcase_19 AC 26 ms
34,200 KB
testcase_20 AC 11 ms
34,304 KB
testcase_21 AC 9 ms
34,236 KB
testcase_22 AC 26 ms
34,228 KB
testcase_23 AC 48 ms
34,372 KB
testcase_24 AC 43 ms
34,320 KB
testcase_25 AC 48 ms
34,268 KB
testcase_26 AC 11 ms
34,324 KB
testcase_27 AC 11 ms
34,272 KB
testcase_28 AC 45 ms
34,276 KB
testcase_29 AC 45 ms
34,592 KB
testcase_30 AC 45 ms
34,300 KB
testcase_31 AC 40 ms
34,440 KB
testcase_32 AC 46 ms
34,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000000000000
#define MOD 1000000007
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N,D;
  cin>>N>>D;

  vector<int> cnt(8000001,0);
  for(int i=1;i<=N;i++){
    cnt[i*i*2]++;
    for(int j=i+1;j<=N;j++){
      cnt[i*i+j*j]+=2;
    }
  }

  int ans=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      int x=i*i-j*j+D;
      if(x>=0&&x<=8000000){
        ans+=cnt[i*i-j*j+D];
      }
    }
  }

  cout<<ans<<endl;

}
0