結果

問題 No.800 四平方定理
ユーザー 👑 jupirojupiro
提出日時 2020-01-14 05:34:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,315 ms / 2,000 ms
コード長 1,330 bytes
コンパイル時間 1,059 ms
コンパイル使用メモリ 119,376 KB
実行使用メモリ 37,800 KB
最終ジャッジ日時 2023-08-25 15:56:34
合計ジャッジ時間 18,648 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,380 KB
testcase_01 AC 16 ms
4,376 KB
testcase_02 AC 11 ms
4,380 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 17 ms
4,380 KB
testcase_07 AC 16 ms
4,380 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 15 ms
4,380 KB
testcase_10 AC 586 ms
19,656 KB
testcase_11 AC 621 ms
36,028 KB
testcase_12 AC 669 ms
36,152 KB
testcase_13 AC 515 ms
19,508 KB
testcase_14 AC 559 ms
36,132 KB
testcase_15 AC 678 ms
36,032 KB
testcase_16 AC 566 ms
36,136 KB
testcase_17 AC 559 ms
36,092 KB
testcase_18 AC 752 ms
36,016 KB
testcase_19 AC 740 ms
36,136 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 766 ms
36,132 KB
testcase_23 AC 1,315 ms
37,552 KB
testcase_24 AC 1,042 ms
36,548 KB
testcase_25 AC 1,314 ms
37,800 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1,039 ms
36,308 KB
testcase_29 AC 1,204 ms
36,880 KB
testcase_30 AC 1,035 ms
36,224 KB
testcase_31 AC 951 ms
36,548 KB
testcase_32 AC 1,096 ms
36,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
//const long long MOD = 1000000007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll N, D; scanf("%lld %lld", &N, &D);

	vector<ll> t;
	for (ll i = 1; i <= N; i++) {
		for (ll j = 1; j <= N; j++) {
			t.push_back(i*i + j * j);
		}
	}
	sort(t.begin(), t.end());
	ll res = 0;
	for (ll i = 1; i <= N; i++) {
		for (ll j = 1; j <= N; j++) {
			ll tmp = j * j - i * i + D;
			res += upper_bound(t.begin(), t.end(), tmp) - lower_bound(t.begin(), t.end(), tmp);
		}
	}
	cout << res << endl;
	return 0;
}
0