結果

問題 No.800 四平方定理
ユーザー akun0716akun0716
提出日時 2020-06-28 20:13:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,334 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 97,228 KB
実行使用メモリ 164,596 KB
最終ジャッジ日時 2023-09-22 10:30:13
合計ジャッジ時間 26,537 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,408 KB
testcase_01 AC 13 ms
5,620 KB
testcase_02 AC 10 ms
5,528 KB
testcase_03 AC 11 ms
5,516 KB
testcase_04 AC 8 ms
4,672 KB
testcase_05 AC 11 ms
5,652 KB
testcase_06 AC 15 ms
5,940 KB
testcase_07 AC 12 ms
5,496 KB
testcase_08 AC 16 ms
6,156 KB
testcase_09 AC 13 ms
5,628 KB
testcase_10 AC 639 ms
58,748 KB
testcase_11 AC 911 ms
82,480 KB
testcase_12 AC 908 ms
82,576 KB
testcase_13 AC 857 ms
82,624 KB
testcase_14 AC 967 ms
82,476 KB
testcase_15 AC 902 ms
82,556 KB
testcase_16 AC 959 ms
82,480 KB
testcase_17 AC 951 ms
82,480 KB
testcase_18 AC 939 ms
82,488 KB
testcase_19 AC 923 ms
82,492 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 932 ms
82,580 KB
testcase_23 AC 1,635 ms
114,588 KB
testcase_24 AC 1,887 ms
164,592 KB
testcase_25 AC 1,543 ms
112,616 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1,957 ms
164,596 KB
testcase_29 TLE -
testcase_30 AC 1,825 ms
117,252 KB
testcase_31 AC 1,712 ms
112,756 KB
testcase_32 AC 1,848 ms
116,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
#include <unordered_map>
#include <iterator>

using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N, D;
	cin >> N >> D;
	unordered_map<int, int>A, B;
	
	
	int ans = 0;
	eFOR(i, 1, N) {
		eFOR(j, i, N) {
			B[i*i + j * j] += 2;
			if (i == j) B[i*i + j * j]--;
		}
	}
	eFOR(i, 1, N) {
		eFOR(j, i, N) {
			ans += B[D + i * i - j * j];
			ans += B[D - i * i + j * j];
			if (i == j)
				ans -= B[D + i * i - j * j];
		}
	}
	cout << ans << endl;
	return 0;
}

0