結果

問題 No.800 四平方定理
ユーザー apoanzanapoanzan
提出日時 2019-03-18 10:51:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 1,419 ms
コンパイル使用メモリ 145,248 KB
実行使用メモリ 143,912 KB
最終ジャッジ日時 2023-09-25 01:09:25
合計ジャッジ時間 5,875 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
143,580 KB
testcase_01 AC 58 ms
143,596 KB
testcase_02 AC 57 ms
143,664 KB
testcase_03 AC 57 ms
143,632 KB
testcase_04 AC 55 ms
143,636 KB
testcase_05 AC 57 ms
143,732 KB
testcase_06 AC 56 ms
143,664 KB
testcase_07 AC 57 ms
143,912 KB
testcase_08 AC 59 ms
143,596 KB
testcase_09 AC 57 ms
143,588 KB
testcase_10 AC 96 ms
143,588 KB
testcase_11 AC 99 ms
143,720 KB
testcase_12 AC 97 ms
143,604 KB
testcase_13 AC 91 ms
143,632 KB
testcase_14 AC 94 ms
143,744 KB
testcase_15 AC 100 ms
143,592 KB
testcase_16 AC 95 ms
143,652 KB
testcase_17 AC 94 ms
143,640 KB
testcase_18 AC 106 ms
143,652 KB
testcase_19 AC 112 ms
143,672 KB
testcase_20 AC 58 ms
143,660 KB
testcase_21 AC 57 ms
143,728 KB
testcase_22 AC 104 ms
143,696 KB
testcase_23 AC 146 ms
143,640 KB
testcase_24 AC 134 ms
143,648 KB
testcase_25 AC 149 ms
143,668 KB
testcase_26 AC 57 ms
143,736 KB
testcase_27 AC 57 ms
143,704 KB
testcase_28 AC 137 ms
143,636 KB
testcase_29 AC 143 ms
143,676 KB
testcase_30 AC 137 ms
143,584 KB
testcase_31 AC 130 ms
143,732 KB
testcase_32 AC 141 ms
143,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int MAX = 9e6;

int main(){
	int n,d;
	cin >> n >> d;
	vector<ll> cnt1(MAX),cnt2(MAX);
	for(int i = 1; i < n+1; ++i){
		for(int j = 1;j < n+1; ++j){
			cnt1[i*i + j*j]++;
			if(i*i - j*j + d > 0) cnt2[i*i - j*j + d]++;
		}
	}
	ll ans = 0;
	for(int i = 0; i < MAX; ++i){
		ans += cnt1[i]*cnt2[i];
	}
	cout << ans << endl;
	return 0;
}
0