結果

問題 No.800 四平方定理
ユーザー tempura_pptempura_pp
提出日時 2019-03-15 15:31:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 166,840 KB
実行使用メモリ 143,868 KB
最終ジャッジ日時 2023-09-14 12:18:25
合計ジャッジ時間 5,933 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
143,576 KB
testcase_01 AC 54 ms
143,764 KB
testcase_02 AC 55 ms
143,684 KB
testcase_03 AC 54 ms
143,600 KB
testcase_04 AC 54 ms
143,600 KB
testcase_05 AC 55 ms
143,512 KB
testcase_06 AC 55 ms
143,524 KB
testcase_07 AC 55 ms
143,624 KB
testcase_08 AC 55 ms
143,520 KB
testcase_09 AC 55 ms
143,568 KB
testcase_10 AC 95 ms
143,572 KB
testcase_11 AC 95 ms
143,680 KB
testcase_12 AC 98 ms
143,696 KB
testcase_13 AC 86 ms
143,664 KB
testcase_14 AC 90 ms
143,572 KB
testcase_15 AC 98 ms
143,684 KB
testcase_16 AC 92 ms
143,700 KB
testcase_17 AC 92 ms
143,596 KB
testcase_18 AC 104 ms
143,604 KB
testcase_19 AC 101 ms
143,684 KB
testcase_20 AC 56 ms
143,572 KB
testcase_21 AC 53 ms
143,680 KB
testcase_22 AC 103 ms
143,624 KB
testcase_23 AC 143 ms
143,660 KB
testcase_24 AC 134 ms
143,688 KB
testcase_25 AC 142 ms
143,628 KB
testcase_26 AC 52 ms
143,868 KB
testcase_27 AC 53 ms
143,688 KB
testcase_28 AC 128 ms
143,868 KB
testcase_29 AC 137 ms
143,512 KB
testcase_30 AC 130 ms
143,808 KB
testcase_31 AC 126 ms
143,576 KB
testcase_32 AC 135 ms
143,624 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 9e6;
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