結果

問題 No.800 四平方定理
ユーザー laftlaft
提出日時 2019-03-17 22:47:48
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 1,240 ms / 2,000 ms
コード長 1,357 bytes
コンパイル時間 1,836 ms
使用メモリ 19,668 KB
最終ジャッジ日時 2023-02-11 10:19:32
合計ジャッジ時間 18,871 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 9 ms
4,900 KB
testcase_01 AC 16 ms
4,900 KB
testcase_02 AC 11 ms
4,904 KB
testcase_03 AC 12 ms
4,900 KB
testcase_04 AC 12 ms
5,156 KB
testcase_05 AC 13 ms
4,904 KB
testcase_06 AC 18 ms
4,904 KB
testcase_07 AC 13 ms
4,900 KB
testcase_08 AC 9 ms
4,900 KB
testcase_09 AC 16 ms
5,156 KB
testcase_10 AC 569 ms
11,400 KB
testcase_11 AC 590 ms
11,468 KB
testcase_12 AC 637 ms
11,496 KB
testcase_13 AC 501 ms
7,256 KB
testcase_14 AC 541 ms
11,468 KB
testcase_15 AC 639 ms
11,404 KB
testcase_16 AC 545 ms
11,404 KB
testcase_17 AC 546 ms
11,452 KB
testcase_18 AC 721 ms
11,548 KB
testcase_19 AC 724 ms
11,448 KB
testcase_20 AC 1 ms
4,900 KB
testcase_21 AC 1 ms
4,900 KB
testcase_22 AC 724 ms
11,452 KB
testcase_23 AC 1,238 ms
19,584 KB
testcase_24 AC 1,021 ms
11,444 KB
testcase_25 AC 1,240 ms
19,592 KB
testcase_26 AC 2 ms
4,900 KB
testcase_27 AC 1 ms
4,900 KB
testcase_28 AC 1,019 ms
11,504 KB
testcase_29 AC 1,155 ms
19,668 KB
testcase_30 AC 1,025 ms
11,452 KB
testcase_31 AC 940 ms
11,396 KB
testcase_32 AC 1,065 ms
19,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using vv = vector<V<T>>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,d;
  cin >> n >> d;
  vi ab;
  REP(i,n){
    int k = (i+1)*(i+1)+d;
    REP(j,n){
      int x = k-(j+1)*(j+1);
      if(x>=2) ab.eb(x);
    }
  }
  sort(ALL(ab));
  ll ans = 0;
  REP(i,n){
    int k = (i+1)*(i+1);
    REP(j,n){
      int x = k+(j+1)*(j+1);
      ans += upper_bound(ALL(ab),x)-lower_bound(ALL(ab),x);
    }
  }
  cout << ans << endl;
}
0