結果

問題 No.800 四平方定理
ユーザー laftlaft
提出日時 2019-03-17 22:47:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,260 ms / 2,000 ms
コード長 1,357 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 204,124 KB
実行使用メモリ 20,504 KB
最終ジャッジ日時 2023-09-22 08:59:29
合計ジャッジ時間 19,508 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,376 KB
testcase_01 AC 15 ms
4,380 KB
testcase_02 AC 11 ms
4,376 KB
testcase_03 AC 12 ms
4,376 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 13 ms
4,376 KB
testcase_06 AC 18 ms
4,376 KB
testcase_07 AC 14 ms
4,376 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 16 ms
4,380 KB
testcase_10 AC 572 ms
12,668 KB
testcase_11 AC 599 ms
11,372 KB
testcase_12 AC 646 ms
11,784 KB
testcase_13 AC 506 ms
7,628 KB
testcase_14 AC 546 ms
12,832 KB
testcase_15 AC 650 ms
12,240 KB
testcase_16 AC 550 ms
11,724 KB
testcase_17 AC 556 ms
12,488 KB
testcase_18 AC 727 ms
11,516 KB
testcase_19 AC 725 ms
11,544 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 731 ms
12,636 KB
testcase_23 AC 1,260 ms
19,988 KB
testcase_24 AC 1,034 ms
11,316 KB
testcase_25 AC 1,255 ms
19,548 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1,053 ms
11,800 KB
testcase_29 AC 1,175 ms
19,556 KB
testcase_30 AC 1,041 ms
11,488 KB
testcase_31 AC 950 ms
12,708 KB
testcase_32 AC 1,071 ms
20,504 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