結果

問題 No.800 四平方定理
ユーザー h28i_Hideh28i_Hide
提出日時 2019-03-17 22:02:39
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 2,632 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 114,268 KB
実行使用メモリ 67,368 KB
最終ジャッジ日時 2023-08-20 12:04:49
合計ジャッジ時間 3,040 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,604 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,464 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,452 KB
testcase_06 AC 2 ms
5,792 KB
testcase_07 AC 3 ms
4,500 KB
testcase_08 AC 3 ms
4,936 KB
testcase_09 AC 2 ms
4,704 KB
testcase_10 AC 34 ms
35,136 KB
testcase_11 AC 39 ms
39,252 KB
testcase_12 AC 40 ms
38,208 KB
testcase_13 AC 34 ms
36,440 KB
testcase_14 AC 38 ms
38,928 KB
testcase_15 AC 40 ms
38,288 KB
testcase_16 AC 39 ms
40,200 KB
testcase_17 AC 38 ms
39,320 KB
testcase_18 AC 45 ms
38,676 KB
testcase_19 AC 44 ms
39,928 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 42 ms
38,728 KB
testcase_23 AC 87 ms
66,180 KB
testcase_24 AC 79 ms
66,408 KB
testcase_25 AC 89 ms
67,344 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 78 ms
66,720 KB
testcase_29 AC 79 ms
65,880 KB
testcase_30 AC 77 ms
66,148 KB
testcase_31 AC 70 ms
61,700 KB
testcase_32 AC 80 ms
67,368 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