結果

問題 No.800 四平方定理
ユーザー h28i_Hideh28i_Hide
提出日時 2019-03-17 22:02:39
言語 C++17(clang Beta)
(clang 13.0.0 + boost 1.78.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 2,632 bytes
コンパイル時間 917 ms
使用メモリ 64,404 KB
最終ジャッジ日時 2023-01-06 18:42:27
合計ジャッジ時間 3,592 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,936 KB
testcase_01 AC 3 ms
4,664 KB
testcase_02 AC 2 ms
4,208 KB
testcase_03 AC 2 ms
4,304 KB
testcase_04 AC 2 ms
4,164 KB
testcase_05 AC 2 ms
4,308 KB
testcase_06 AC 2 ms
4,768 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,784 KB
testcase_09 AC 2 ms
4,592 KB
testcase_10 AC 49 ms
33,468 KB
testcase_11 AC 55 ms
37,288 KB
testcase_12 AC 56 ms
36,716 KB
testcase_13 AC 50 ms
34,896 KB
testcase_14 AC 52 ms
37,196 KB
testcase_15 AC 55 ms
37,008 KB
testcase_16 AC 53 ms
37,568 KB
testcase_17 AC 52 ms
37,592 KB
testcase_18 AC 58 ms
37,508 KB
testcase_19 AC 61 ms
37,560 KB
testcase_20 AC 2 ms
3,368 KB
testcase_21 AC 1 ms
3,320 KB
testcase_22 AC 61 ms
37,684 KB
testcase_23 AC 125 ms
64,400 KB
testcase_24 AC 112 ms
64,404 KB
testcase_25 AC 122 ms
64,272 KB
testcase_26 AC 1 ms
3,404 KB
testcase_27 AC 2 ms
3,380 KB
testcase_28 AC 111 ms
64,208 KB
testcase_29 AC 116 ms
64,292 KB
testcase_30 AC 110 ms
64,192 KB
testcase_31 AC 102 ms
59,896 KB
testcase_32 AC 114 ms
64,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L;
ll ans;
/*
string S,T;
ll y[101010];
ll a[101010];
ll b[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
*/
ll tmp[40000000];
int main() {
    cin>>N>>D;
    map<ll,ll> mp1;
    rep(i,1,N+1){
        rep(j,1,N+1){
            tmp[i*i+j*j]++;
        }
    }
    rep(i,1,N+1){
        rep(j,1,N+1){
            if(i*i-j*j+D>=0)
                ans+=tmp[i*i-j*j+D];
        }
    }
    cout<<ans<<endl;
	return 0;
}
0