結果

問題 No.800 四平方定理
ユーザー utouto97utouto97
提出日時 2019-03-17 22:31:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 777 bytes
コンパイル時間 1,179 ms
コンパイル使用メモリ 145,200 KB
実行使用メモリ 65,736 KB
最終ジャッジ日時 2023-09-22 08:09:30
合計ジャッジ時間 4,175 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
65,468 KB
testcase_01 AC 19 ms
65,356 KB
testcase_02 AC 19 ms
65,360 KB
testcase_03 AC 19 ms
65,532 KB
testcase_04 AC 20 ms
65,400 KB
testcase_05 AC 19 ms
65,452 KB
testcase_06 AC 21 ms
65,472 KB
testcase_07 AC 20 ms
65,424 KB
testcase_08 AC 20 ms
65,520 KB
testcase_09 AC 19 ms
65,348 KB
testcase_10 AC 46 ms
65,536 KB
testcase_11 AC 53 ms
65,464 KB
testcase_12 AC 53 ms
65,460 KB
testcase_13 AC 41 ms
65,532 KB
testcase_14 AC 50 ms
65,348 KB
testcase_15 AC 50 ms
65,480 KB
testcase_16 AC 46 ms
65,396 KB
testcase_17 AC 50 ms
65,484 KB
testcase_18 AC 59 ms
65,424 KB
testcase_19 AC 54 ms
65,532 KB
testcase_20 AC 20 ms
65,732 KB
testcase_21 AC 20 ms
65,584 KB
testcase_22 AC 55 ms
65,472 KB
testcase_23 WA -
testcase_24 AC 79 ms
65,528 KB
testcase_25 WA -
testcase_26 AC 20 ms
65,736 KB
testcase_27 AC 19 ms
65,412 KB
testcase_28 AC 82 ms
65,472 KB
testcase_29 WA -
testcase_30 AC 80 ms
65,428 KB
testcase_31 AC 76 ms
65,524 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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
}*/

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

  vi a(8000001);
  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 <= 2000*2000)
        ans += a[t];
    }
  }

  cout << ans << endl;

  return 0;
}
0