結果

問題 No.800 四平方定理
ユーザー hazohelhazohel
提出日時 2019-03-20 14:45:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 55,628 KB
実行使用メモリ 66,120 KB
最終ジャッジ日時 2023-10-19 04:22:38
合計ジャッジ時間 3,248 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
66,120 KB
testcase_01 AC 26 ms
66,120 KB
testcase_02 AC 25 ms
66,120 KB
testcase_03 AC 26 ms
66,120 KB
testcase_04 AC 26 ms
66,120 KB
testcase_05 AC 26 ms
66,120 KB
testcase_06 AC 26 ms
66,120 KB
testcase_07 AC 26 ms
66,120 KB
testcase_08 AC 27 ms
66,120 KB
testcase_09 AC 26 ms
66,120 KB
testcase_10 AC 47 ms
66,120 KB
testcase_11 AC 50 ms
66,120 KB
testcase_12 AC 51 ms
66,120 KB
testcase_13 AC 44 ms
66,120 KB
testcase_14 AC 48 ms
66,120 KB
testcase_15 AC 52 ms
66,120 KB
testcase_16 AC 49 ms
66,120 KB
testcase_17 AC 52 ms
66,120 KB
testcase_18 AC 56 ms
66,120 KB
testcase_19 AC 56 ms
66,120 KB
testcase_20 AC 25 ms
66,120 KB
testcase_21 AC 26 ms
66,120 KB
testcase_22 AC 54 ms
66,120 KB
testcase_23 AC 101 ms
66,120 KB
testcase_24 AC 93 ms
66,120 KB
testcase_25 AC 103 ms
66,120 KB
testcase_26 AC 26 ms
66,120 KB
testcase_27 AC 25 ms
66,120 KB
testcase_28 AC 90 ms
66,120 KB
testcase_29 AC 97 ms
66,120 KB
testcase_30 AC 91 ms
66,120 KB
testcase_31 AC 84 ms
66,120 KB
testcase_32 AC 93 ms
66,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
#define INF 8000001

int N, D;
int LEFT[INF];
int RIGHT[INF];

int main(){
  cin >> N >> D;
  for(int i = 0; i < INF; ++i){
    LEFT[i] = 0;
    RIGHT[i] = 0;
  }
  for(int x = 1;x <= N; ++x){
    for(int y = 1; y <= N; ++y){
      LEFT[x*x+y*y]++;
    }
  }
  for(int z = 1;z <= N; ++z){
    for(int w = 1; w <= N; ++w){
      if(w*w-z*z +D >0){
        RIGHT[w*w - z*z + D]++;
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < INF; ++i){
    ans += LEFT[i] * RIGHT[i];
  }
  cout << ans << endl;
}
0