結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
81,164 KB
testcase_01 AC 32 ms
81,172 KB
testcase_02 AC 32 ms
81,036 KB
testcase_03 AC 32 ms
81,204 KB
testcase_04 AC 31 ms
81,032 KB
testcase_05 AC 31 ms
81,056 KB
testcase_06 AC 32 ms
81,092 KB
testcase_07 AC 32 ms
81,108 KB
testcase_08 AC 33 ms
81,032 KB
testcase_09 AC 32 ms
81,088 KB
testcase_10 AC 75 ms
81,176 KB
testcase_11 AC 79 ms
81,036 KB
testcase_12 AC 80 ms
81,284 KB
testcase_13 AC 70 ms
81,352 KB
testcase_14 AC 74 ms
81,164 KB
testcase_15 AC 83 ms
81,076 KB
testcase_16 AC 74 ms
81,036 KB
testcase_17 AC 73 ms
81,080 KB
testcase_18 AC 87 ms
81,104 KB
testcase_19 AC 86 ms
81,092 KB
testcase_20 AC 30 ms
81,116 KB
testcase_21 AC 32 ms
81,172 KB
testcase_22 AC 88 ms
81,116 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 32 ms
81,120 KB
testcase_27 AC 32 ms
81,080 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