結果

問題 No.800 四平方定理
ユーザー DaYuanChiDaYuanChi
提出日時 2021-01-26 01:23:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 164,556 KB
実行使用メモリ 56,608 KB
最終ジャッジ日時 2023-09-05 04:39:05
合計ジャッジ時間 5,978 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,568 KB
testcase_01 AC 7 ms
5,708 KB
testcase_02 AC 6 ms
5,828 KB
testcase_03 AC 6 ms
5,620 KB
testcase_04 AC 6 ms
5,588 KB
testcase_05 AC 6 ms
5,752 KB
testcase_06 AC 6 ms
5,848 KB
testcase_07 AC 7 ms
5,940 KB
testcase_08 AC 7 ms
6,076 KB
testcase_09 AC 7 ms
5,644 KB
testcase_10 AC 33 ms
30,044 KB
testcase_11 AC 35 ms
31,952 KB
testcase_12 AC 35 ms
34,008 KB
testcase_13 AC 27 ms
27,924 KB
testcase_14 AC 32 ms
32,000 KB
testcase_15 AC 36 ms
34,032 KB
testcase_16 AC 35 ms
31,968 KB
testcase_17 AC 32 ms
32,088 KB
testcase_18 AC 37 ms
36,080 KB
testcase_19 AC 38 ms
36,092 KB
testcase_20 AC 6 ms
5,404 KB
testcase_21 AC 6 ms
5,416 KB
testcase_22 AC 38 ms
36,324 KB
testcase_23 AC 95 ms
56,596 KB
testcase_24 AC 85 ms
52,576 KB
testcase_25 AC 95 ms
56,608 KB
testcase_26 AC 7 ms
5,404 KB
testcase_27 AC 7 ms
7,396 KB
testcase_28 AC 84 ms
52,448 KB
testcase_29 AC 81 ms
54,528 KB
testcase_30 AC 79 ms
52,696 KB
testcase_31 AC 72 ms
50,452 KB
testcase_32 AC 87 ms
52,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int cnt1[10000000];
int cnt2[10000000];

int main(){
  int n, d; cin >> n >> d;
  for(int x = 1; x <= n; x++){
    for(int y = 1; y <= n; y++){
      cnt1[x*x+y*y]++;
    }
  }
  for(int z = 1; z <= n; z++){
    for(int w = 1; w <= n; w++){
      if(-z*z+w*w+d<0) continue;
      cnt2[-z*z+w*w+d]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < 1e7; i++){
    ans += cnt1[i]*cnt2[i];
  }
  cout << ans << endl;
  return 0;
}
  
0