結果

問題 No.800 四平方定理
ユーザー tempura_pptempura_pp
提出日時 2019-03-14 13:50:12
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 403 bytes
コンパイル時間 1,307 ms
使用メモリ 81,432 KB
最終ジャッジ日時 2023-02-02 02:54:47
合計ジャッジ時間 8,722 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 28 ms
81,128 KB
testcase_01 AC 30 ms
81,152 KB
testcase_02 AC 30 ms
81,192 KB
testcase_03 AC 30 ms
81,160 KB
testcase_04 AC 29 ms
81,184 KB
testcase_05 AC 29 ms
81,116 KB
testcase_06 AC 30 ms
81,236 KB
testcase_07 AC 30 ms
81,108 KB
testcase_08 AC 30 ms
81,200 KB
testcase_09 AC 29 ms
81,236 KB
testcase_10 AC 56 ms
81,112 KB
testcase_11 AC 56 ms
81,188 KB
testcase_12 AC 63 ms
81,180 KB
testcase_13 AC 53 ms
81,152 KB
testcase_14 AC 54 ms
81,184 KB
testcase_15 AC 57 ms
81,240 KB
testcase_16 AC 55 ms
81,252 KB
testcase_17 AC 53 ms
81,164 KB
testcase_18 AC 67 ms
81,108 KB
testcase_19 AC 64 ms
81,156 KB
testcase_20 AC 30 ms
81,232 KB
testcase_21 AC 29 ms
81,108 KB
testcase_22 AC 67 ms
81,108 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 52 ms
81,116 KB
testcase_27 AC 29 ms
81,116 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 REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

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