結果

問題 No.800 四平方定理
ユーザー rabimearabimea
提出日時 2023-01-25 02:49:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 777 bytes
コンパイル時間 2,636 ms
コンパイル使用メモリ 197,208 KB
実行使用メモリ 20,588 KB
最終ジャッジ日時 2023-09-08 17:11:57
合計ジャッジ時間 7,344 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,404 KB
testcase_01 AC 2 ms
5,460 KB
testcase_02 AC 2 ms
5,404 KB
testcase_03 AC 2 ms
5,408 KB
testcase_04 AC 3 ms
5,408 KB
testcase_05 AC 2 ms
5,412 KB
testcase_06 AC 2 ms
5,400 KB
testcase_07 AC 2 ms
5,704 KB
testcase_08 AC 3 ms
5,392 KB
testcase_09 AC 2 ms
5,472 KB
testcase_10 AC 12 ms
13,588 KB
testcase_11 RE -
testcase_12 AC 13 ms
13,668 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 14 ms
13,828 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 15 ms
13,796 KB
testcase_19 AC 14 ms
13,596 KB
testcase_20 AC 2 ms
5,392 KB
testcase_21 AC 2 ms
5,456 KB
testcase_22 AC 15 ms
15,760 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
5,520 KB
testcase_27 AC 2 ms
5,400 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
using vi = vector <int>;
using ll = long long;
using pii = pair <int, int>;
//~ const ll mod = 998244353;
const ll mod = 1e9 + 7;
ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a;
	for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; }

const int N = 2011;
const int M = N * N;
int _mp[M * 2 + 1];

int main() {
	ios :: sync_with_stdio(false);
	
	int n, d; cin >> n >> d;
	
	int *mp = _mp + M;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= i; j ++)
			mp[i * i - j * j] ++;
	
	ll ans = 0;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++) {
			int x = i * i + j * j - d;
			if(x < 0) x = -x;
			ans += mp[x];
		}
	cout << ans << '\n';
}
0