結果

問題 No.800 四平方定理
ユーザー le_panda_noirle_panda_noir
提出日時 2020-06-13 19:55:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 858 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 77,260 KB
実行使用メモリ 73,864 KB
最終ジャッジ日時 2023-09-08 02:32:18
合計ジャッジ時間 3,745 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
73,608 KB
testcase_01 AC 33 ms
73,624 KB
testcase_02 AC 33 ms
73,628 KB
testcase_03 AC 33 ms
73,624 KB
testcase_04 AC 33 ms
73,616 KB
testcase_05 AC 34 ms
73,564 KB
testcase_06 AC 33 ms
73,616 KB
testcase_07 AC 34 ms
73,660 KB
testcase_08 AC 34 ms
73,576 KB
testcase_09 AC 34 ms
73,628 KB
testcase_10 AC 54 ms
73,612 KB
testcase_11 AC 58 ms
73,616 KB
testcase_12 AC 58 ms
73,612 KB
testcase_13 AC 56 ms
73,568 KB
testcase_14 AC 59 ms
73,568 KB
testcase_15 AC 59 ms
73,680 KB
testcase_16 AC 60 ms
73,584 KB
testcase_17 AC 59 ms
73,628 KB
testcase_18 AC 60 ms
73,852 KB
testcase_19 AC 59 ms
73,708 KB
testcase_20 AC 34 ms
73,720 KB
testcase_21 AC 33 ms
73,580 KB
testcase_22 AC 59 ms
73,564 KB
testcase_23 AC 84 ms
73,864 KB
testcase_24 AC 86 ms
73,612 KB
testcase_25 AC 85 ms
73,848 KB
testcase_26 AC 33 ms
73,852 KB
testcase_27 AC 33 ms
73,848 KB
testcase_28 AC 85 ms
73,584 KB
testcase_29 AC 84 ms
73,620 KB
testcase_30 AC 82 ms
73,620 KB
testcase_31 AC 79 ms
73,612 KB
testcase_32 AC 83 ms
73,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>

using namespace std;
using ll = long long;

void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(int i=0,_i=(n);i<_i;++i)
#define _rep3(i,a,b) for(int i=(a),_i=(b),_ii=(b)>(a)?1:-1;abs(_i-i)>0;i+=_ii)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)

constexpr int MAX_N = 3000;
int m[MAX_N*MAX_N+1], m2[MAX_N*MAX_N+1];
int main() {
  int N, D;
  ins(N, D);

  rep(i, MAX_N*MAX_N+1)
    m[i] = m2[i] = 0;
  m2[0] += N;
  rep(i, N) {
    ++m[2*(i+1)*(i+1)];
    rep(j, i+1, N) {
      m[(i+1)*(i+1)+(j+1)*(j+1)] += 2;
      ++m2[(j+1)*(j+1)-(i+1)*(i+1)];
    }
  }
  ll ans = 0;
  rep(i, MAX_N*MAX_N+1) {
    ans += m2[abs(i-D)] * m[i];
  }
  cout << ans << endl;

  return 0;
}
0