結果

問題 No.800 四平方定理
ユーザー tempura_pptempura_pp
提出日時 2019-03-14 14:51:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 448 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 165,796 KB
実行使用メモリ 81,256 KB
最終ジャッジ日時 2023-09-14 12:11:11
合計ジャッジ時間 4,984 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
81,104 KB
testcase_01 AC 32 ms
81,124 KB
testcase_02 AC 31 ms
81,040 KB
testcase_03 AC 31 ms
81,032 KB
testcase_04 AC 33 ms
81,172 KB
testcase_05 AC 32 ms
81,156 KB
testcase_06 AC 33 ms
81,100 KB
testcase_07 AC 31 ms
81,188 KB
testcase_08 AC 32 ms
81,152 KB
testcase_09 AC 31 ms
81,052 KB
testcase_10 AC 71 ms
81,152 KB
testcase_11 AC 76 ms
81,112 KB
testcase_12 AC 76 ms
81,252 KB
testcase_13 AC 66 ms
81,068 KB
testcase_14 AC 70 ms
81,052 KB
testcase_15 AC 77 ms
81,132 KB
testcase_16 AC 71 ms
81,100 KB
testcase_17 AC 71 ms
81,140 KB
testcase_18 AC 83 ms
81,108 KB
testcase_19 AC 85 ms
81,256 KB
testcase_20 AC 31 ms
81,196 KB
testcase_21 AC 31 ms
81,128 KB
testcase_22 AC 81 ms
81,100 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 32 ms
81,048 KB
testcase_27 AC 31 ms
81,232 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;
	assert(1<=n&&n<=1500);
	assert(0<=d&&d<=1000000);
	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;
	return 0;
}
0