結果

問題 No.800 四平方定理
ユーザー CleyLCleyL
提出日時 2023-06-29 12:31:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 73,652 KB
実行使用メモリ 96,856 KB
最終ジャッジ日時 2023-09-20 07:56:25
合計ジャッジ時間 4,480 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 4 ms
4,984 KB
testcase_02 AC 3 ms
4,436 KB
testcase_03 AC 3 ms
4,424 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,384 KB
testcase_06 AC 3 ms
5,292 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
5,020 KB
testcase_10 AC 48 ms
49,528 KB
testcase_11 AC 53 ms
55,324 KB
testcase_12 AC 55 ms
54,284 KB
testcase_13 AC 48 ms
51,492 KB
testcase_14 AC 52 ms
55,056 KB
testcase_15 AC 56 ms
55,112 KB
testcase_16 AC 53 ms
55,892 KB
testcase_17 AC 54 ms
55,788 KB
testcase_18 AC 56 ms
55,724 KB
testcase_19 AC 58 ms
55,580 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 56 ms
55,960 KB
testcase_23 AC 105 ms
96,856 KB
testcase_24 AC 101 ms
96,764 KB
testcase_25 AC 100 ms
96,416 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 100 ms
96,304 KB
testcase_29 AC 104 ms
96,744 KB
testcase_30 AC 100 ms
96,504 KB
testcase_31 AC 90 ms
90,044 KB
testcase_32 AC 103 ms
96,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main(){
  long long n,d;cin>>n>>d;
  vector<long long> A(n*n*2+1);
  vector<long long> B(n*n+1);
  for(int i = 1; n >= i; i++){
    for(int j = i; n >= j; j++){
      if(n*n-1+d >= i*i+j*j){
        A[i*i+j*j] += (i==j?1:2);
      }
      if(n*n+n*n+d >= j*j-i*i){
        B[j*j-i*i]++;
      }
    }
  }
  long long ans = 0;
  for(int i = 0; 2*n*n >= i; i++){
    ans += A[i]*B[abs(i-d)];
  }
  cout << ans << endl;
}
0