結果

問題 No.800 四平方定理
ユーザー CleyLCleyL
提出日時 2023-06-29 12:32:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 403 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 159,452 KB
最終ジャッジ日時 2023-09-20 07:57:30
合計ジャッジ時間 3,875 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,780 KB
testcase_01 AC 4 ms
5,900 KB
testcase_02 AC 3 ms
5,212 KB
testcase_03 AC 4 ms
5,452 KB
testcase_04 AC 3 ms
4,920 KB
testcase_05 AC 4 ms
5,184 KB
testcase_06 AC 5 ms
6,416 KB
testcase_07 AC 4 ms
5,684 KB
testcase_08 RE -
testcase_09 AC 5 ms
5,952 KB
testcase_10 AC 53 ms
80,272 KB
testcase_11 AC 60 ms
90,140 KB
testcase_12 AC 61 ms
88,532 KB
testcase_13 AC 57 ms
83,940 KB
testcase_14 AC 58 ms
90,044 KB
testcase_15 AC 57 ms
89,784 KB
testcase_16 AC 60 ms
90,864 KB
testcase_17 AC 60 ms
90,788 KB
testcase_18 AC 60 ms
90,548 KB
testcase_19 AC 59 ms
90,868 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 60 ms
90,800 KB
testcase_23 AC 121 ms
159,348 KB
testcase_24 AC 131 ms
159,452 KB
testcase_25 AC 106 ms
158,876 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 RE -
testcase_28 AC 113 ms
158,568 KB
testcase_29 AC 113 ms
159,056 KB
testcase_30 AC 114 ms
158,908 KB
testcase_31 AC 101 ms
147,896 KB
testcase_32 AC 111 ms
159,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  long long n,d;cin>>n>>d;
  vector<long long> A(n*n*3+1);
  vector<long long> B(n*n*2+1);
  for(int i = 1; n >= i; i++){
    for(int j = i; n >= j; j++){
      A[i*i+j*j] += (i==j?1:2);
      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