結果

問題 No.800 四平方定理
ユーザー utouto97utouto97
提出日時 2019-03-17 22:33:23
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 1,784 ms
使用メモリ 64,512 KB
最終ジャッジ日時 2023-02-11 09:23:05
合計ジャッジ時間 4,463 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,036 KB
testcase_01 AC 2 ms
4,652 KB
testcase_02 AC 2 ms
4,292 KB
testcase_03 AC 2 ms
4,364 KB
testcase_04 AC 2 ms
4,148 KB
testcase_05 AC 2 ms
4,340 KB
testcase_06 AC 3 ms
4,832 KB
testcase_07 AC 2 ms
4,496 KB
testcase_08 AC 3 ms
4,896 KB
testcase_09 AC 2 ms
4,588 KB
testcase_10 AC 53 ms
33,624 KB
testcase_11 AC 58 ms
37,392 KB
testcase_12 AC 64 ms
36,700 KB
testcase_13 AC 54 ms
34,936 KB
testcase_14 AC 57 ms
37,356 KB
testcase_15 AC 60 ms
37,048 KB
testcase_16 AC 57 ms
37,752 KB
testcase_17 AC 60 ms
37,648 KB
testcase_18 AC 63 ms
37,608 KB
testcase_19 AC 62 ms
37,676 KB
testcase_20 AC 1 ms
3,364 KB
testcase_21 AC 2 ms
3,468 KB
testcase_22 AC 65 ms
37,712 KB
testcase_23 AC 132 ms
64,396 KB
testcase_24 AC 123 ms
64,464 KB
testcase_25 AC 132 ms
64,220 KB
testcase_26 AC 1 ms
3,472 KB
testcase_27 AC 2 ms
3,372 KB
testcase_28 AC 122 ms
64,096 KB
testcase_29 AC 127 ms
64,328 KB
testcase_30 AC 122 ms
64,140 KB
testcase_31 AC 112 ms
59,976 KB
testcase_32 AC 123 ms
64,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  x^2+y^2+z^2-w^2 = D
}*/
int a[8000001];

signed main()
{
  int n, d;
  cin >> n >> d;

  repi(i, 1, n+1){
    repi(j, 1, n+1){
      a[i*i+j*j]++;
    }
  }

  int ans = 0;
  repi(i, 1, n+1){
    repi(j, 1, n+1){
      int t = d-(i*i-j*j);
      if(0 <= t and t <= 8000001)
        ans += a[t];
    }
  }

  cout << ans << endl;

  return 0;
}
0