結果

問題 No.800 四平方定理
ユーザー taki_gtaki_g
提出日時 2019-03-18 14:25:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 1,417 ms
コンパイル使用メモリ 165,812 KB
実行使用メモリ 143,956 KB
最終ジャッジ日時 2023-09-25 10:41:12
合計ジャッジ時間 5,900 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
143,804 KB
testcase_01 AC 49 ms
143,800 KB
testcase_02 AC 49 ms
143,656 KB
testcase_03 AC 50 ms
143,872 KB
testcase_04 AC 48 ms
143,928 KB
testcase_05 AC 48 ms
143,808 KB
testcase_06 AC 48 ms
143,808 KB
testcase_07 AC 50 ms
143,696 KB
testcase_08 AC 49 ms
143,800 KB
testcase_09 AC 49 ms
143,740 KB
testcase_10 AC 74 ms
143,660 KB
testcase_11 AC 75 ms
143,952 KB
testcase_12 AC 77 ms
143,608 KB
testcase_13 AC 70 ms
143,676 KB
testcase_14 AC 71 ms
143,684 KB
testcase_15 AC 76 ms
143,672 KB
testcase_16 AC 73 ms
143,808 KB
testcase_17 AC 74 ms
143,760 KB
testcase_18 AC 78 ms
143,628 KB
testcase_19 AC 78 ms
143,748 KB
testcase_20 AC 48 ms
143,728 KB
testcase_21 AC 49 ms
143,792 KB
testcase_22 AC 78 ms
143,660 KB
testcase_23 AC 108 ms
143,956 KB
testcase_24 AC 100 ms
143,772 KB
testcase_25 AC 106 ms
143,728 KB
testcase_26 AC 48 ms
143,868 KB
testcase_27 AC 47 ms
143,800 KB
testcase_28 AC 99 ms
143,608 KB
testcase_29 AC 103 ms
143,700 KB
testcase_30 AC 100 ms
143,868 KB
testcase_31 AC 93 ms
143,792 KB
testcase_32 AC 102 ms
143,700 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