結果

問題 No.800 四平方定理
ユーザー izryt(趣味)izryt(趣味)
提出日時 2020-05-24 09:38:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 98,268 KB
実行使用メモリ 34,560 KB
最終ジャッジ日時 2024-04-19 07:15:49
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 19 ms
19,072 KB
testcase_11 AC 34 ms
20,736 KB
testcase_12 AC 35 ms
20,352 KB
testcase_13 AC 30 ms
19,712 KB
testcase_14 AC 33 ms
20,864 KB
testcase_15 AC 37 ms
20,736 KB
testcase_16 AC 35 ms
20,864 KB
testcase_17 AC 35 ms
20,864 KB
testcase_18 AC 39 ms
20,864 KB
testcase_19 AC 41 ms
20,992 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 38 ms
21,120 KB
testcase_23 AC 93 ms
34,432 KB
testcase_24 AC 83 ms
34,560 KB
testcase_25 AC 91 ms
34,176 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 85 ms
34,304 KB
testcase_29 AC 88 ms
34,432 KB
testcase_30 AC 82 ms
34,432 KB
testcase_31 AC 76 ms
32,000 KB
testcase_32 AC 85 ms
34,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <unordered_map>

using namespace std;

//#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
//int read(){int a;scanf("%lld",&a);return a;}

const int inf = 1e9 + 10;
const int mod = 1e9 + 7;

int N, D;
int xy[8000800];
unordered_map<int, int> zw;

signed main()
{
	cin >> N >> D;

	range(x, 1, N + 1) {
		range(y, 1, N + 1) {
			xy[x * x + y * y]++;
		}
	}

	ll ans = 0;

	range(z, 1, N + 1) {
		range(w, 1, N + 1) {
			int a = D - w * w + z * z;
			if (0 <= a and a <= N * N * 2) {
				ans += xy[a];
			}
		}
	}

	printf("%lld\n", ans);
}

0