結果

問題 No.800 四平方定理
ユーザー misora192misora192
提出日時 2020-05-15 09:08:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 668 bytes
コンパイル時間 2,015 ms
コンパイル使用メモリ 174,424 KB
実行使用メモリ 56,080 KB
最終ジャッジ日時 2023-10-17 17:55:06
合計ジャッジ時間 9,405 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,724 KB
testcase_01 AC 37 ms
5,560 KB
testcase_02 AC 26 ms
5,016 KB
testcase_03 AC 28 ms
5,184 KB
testcase_04 AC 24 ms
4,932 KB
testcase_05 AC 28 ms
5,136 KB
testcase_06 AC 44 ms
5,932 KB
testcase_07 AC 32 ms
5,388 KB
testcase_08 AC 36 ms
5,892 KB
testcase_09 AC 39 ms
5,644 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, d;
	cin >> n >> d;

	map<int, int> mp;
	rep(z, n) rep(w, n){
		int a = (w + 1) * (w + 1) - (z + 1) * (z + 1) + d;
		if(mp.count(a) == 0) mp[a] = 0;
		mp[a]++;
	}

	int ans = 0;
	rep(x, n) rep(y, n){
		int a = (x + 1) * (x + 1) + (y + 1) * (y + 1);
		if(mp.count(a) > 0) ans += mp[a];
	}

	cout << ans << endl;
}
0