結果

問題 No.800 四平方定理
ユーザー dsm4up2cdsm4up2c
提出日時 2019-03-18 00:47:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 73,472 KB
実行使用メモリ 128,152 KB
最終ジャッジ日時 2023-09-22 16:18:04
合計ジャッジ時間 3,516 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 4 ms
5,452 KB
testcase_02 AC 3 ms
4,680 KB
testcase_03 AC 3 ms
4,832 KB
testcase_04 AC 3 ms
4,676 KB
testcase_05 AC 3 ms
4,816 KB
testcase_06 AC 4 ms
5,924 KB
testcase_07 AC 3 ms
5,184 KB
testcase_08 AC 4 ms
5,976 KB
testcase_09 AC 4 ms
5,408 KB
testcase_10 AC 56 ms
64,904 KB
testcase_11 AC 61 ms
72,640 KB
testcase_12 AC 62 ms
71,396 KB
testcase_13 AC 56 ms
67,816 KB
testcase_14 AC 59 ms
72,752 KB
testcase_15 AC 66 ms
72,076 KB
testcase_16 AC 60 ms
73,448 KB
testcase_17 AC 60 ms
73,460 KB
testcase_18 AC 68 ms
72,888 KB
testcase_19 AC 68 ms
73,144 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 67 ms
73,396 KB
testcase_23 AC 132 ms
128,108 KB
testcase_24 AC 118 ms
128,152 KB
testcase_25 AC 129 ms
127,840 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 117 ms
127,436 KB
testcase_29 AC 122 ms
127,952 KB
testcase_30 AC 116 ms
127,704 KB
testcase_31 AC 108 ms
119,016 KB
testcase_32 AC 119 ms
128,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,d;
	cin>>n>>d;
	vector<ll> cnt_xy(2*n*n+1,0),cnt_wz(2*n*n+1,0);

	for(ll x = 1; x <= n; x++){
		for(ll y = 1; y <= n; y++){
			ll res = x*x + y*y;
			cnt_xy[res]++;
		}
	}
	for(ll w = 1; w <= n; w++){
		for(ll z = 1; z <= n; z++){
			ll res = w*w-z*z+d;
			if(res>=1 && res <= 2*n*n) cnt_wz[res]++;
		}
	}
	ll ans=0;
	for(int i = 1; i <= 2*n*n; i++){
		ans += cnt_xy[i]*cnt_wz[i];
	}
	cout << ans << endl;

	return 0;
}
0