結果

問題 No.800 四平方定理
ユーザー hazohelhazohel
提出日時 2019-03-20 14:15:09
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 545 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 55,740 KB
実行使用メモリ 42,692 KB
最終ジャッジ日時 2023-10-19 03:56:45
合計ジャッジ時間 4,587 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
42,692 KB
testcase_01 AC 18 ms
42,692 KB
testcase_02 AC 17 ms
42,692 KB
testcase_03 AC 17 ms
42,692 KB
testcase_04 AC 18 ms
42,692 KB
testcase_05 AC 18 ms
42,692 KB
testcase_06 AC 17 ms
42,692 KB
testcase_07 AC 18 ms
42,692 KB
testcase_08 AC 18 ms
42,692 KB
testcase_09 AC 18 ms
42,692 KB
testcase_10 AC 37 ms
42,692 KB
testcase_11 AC 44 ms
42,692 KB
testcase_12 AC 46 ms
42,692 KB
testcase_13 AC 37 ms
42,692 KB
testcase_14 AC 40 ms
42,692 KB
testcase_15 AC 43 ms
42,692 KB
testcase_16 AC 40 ms
42,692 KB
testcase_17 AC 42 ms
42,692 KB
testcase_18 AC 45 ms
42,692 KB
testcase_19 AC 44 ms
42,692 KB
testcase_20 AC 18 ms
42,692 KB
testcase_21 AC 17 ms
42,692 KB
testcase_22 AC 44 ms
42,692 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 18 ms
42,692 KB
testcase_27 AC 17 ms
42,692 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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