結果

問題 No.800 四平方定理
ユーザー ransewhaleransewhale
提出日時 2019-03-18 11:51:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 144,060 KB
実行使用メモリ 65,128 KB
最終ジャッジ日時 2023-09-25 05:57:51
合計ジャッジ時間 3,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,520 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,748 KB
testcase_07 AC 3 ms
4,712 KB
testcase_08 AC 3 ms
4,748 KB
testcase_09 AC 2 ms
4,752 KB
testcase_10 AC 32 ms
36,160 KB
testcase_11 AC 37 ms
38,284 KB
testcase_12 AC 37 ms
38,348 KB
testcase_13 AC 32 ms
36,116 KB
testcase_14 AC 35 ms
38,364 KB
testcase_15 AC 36 ms
38,288 KB
testcase_16 AC 38 ms
40,216 KB
testcase_17 AC 36 ms
40,524 KB
testcase_18 AC 41 ms
40,404 KB
testcase_19 AC 39 ms
40,216 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 40 ms
40,268 KB
testcase_23 AC 89 ms
65,076 KB
testcase_24 AC 80 ms
65,128 KB
testcase_25 AC 83 ms
64,980 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 79 ms
64,904 KB
testcase_29 AC 81 ms
65,016 KB
testcase_30 AC 81 ms
65,128 KB
testcase_31 AC 70 ms
62,800 KB
testcase_32 AC 81 ms
64,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

ll cnt[8004004];

int main(void){
	int n,d,i,j,p;
	ll ans=0ll;
	cin >> n >> d;
	for(i=1; i<=n; ++i){
		for(j=1; j<=n; ++j){
			++cnt[i*i+j*j];
		}
	}
	for(i=1; i<=n; ++i){
		for(j=1; j<=n; ++j){
			p = j*j-i*i+d;
			if(0<=p && p<=8000000){
				ans += cnt[p];
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0