結果

問題 No.800 四平方定理
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-05 05:19:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 52,364 KB
実行使用メモリ 159,904 KB
最終ジャッジ日時 2023-09-17 00:01:45
合計ジャッジ時間 5,502 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
159,768 KB
testcase_01 AC 67 ms
159,712 KB
testcase_02 AC 67 ms
159,608 KB
testcase_03 AC 67 ms
159,764 KB
testcase_04 AC 67 ms
159,716 KB
testcase_05 AC 66 ms
159,620 KB
testcase_06 AC 67 ms
159,620 KB
testcase_07 AC 68 ms
159,656 KB
testcase_08 AC 79 ms
159,660 KB
testcase_09 AC 57 ms
159,620 KB
testcase_10 AC 95 ms
159,748 KB
testcase_11 AC 96 ms
159,592 KB
testcase_12 AC 100 ms
159,692 KB
testcase_13 AC 115 ms
159,592 KB
testcase_14 AC 86 ms
159,648 KB
testcase_15 AC 94 ms
159,764 KB
testcase_16 AC 86 ms
159,748 KB
testcase_17 AC 85 ms
159,592 KB
testcase_18 AC 95 ms
159,648 KB
testcase_19 AC 94 ms
159,596 KB
testcase_20 AC 54 ms
159,712 KB
testcase_21 AC 55 ms
159,652 KB
testcase_22 AC 96 ms
159,764 KB
testcase_23 AC 127 ms
159,900 KB
testcase_24 AC 115 ms
159,744 KB
testcase_25 AC 129 ms
159,692 KB
testcase_26 AC 55 ms
159,588 KB
testcase_27 AC 56 ms
159,904 KB
testcase_28 AC 116 ms
159,736 KB
testcase_29 AC 123 ms
159,764 KB
testcase_30 AC 112 ms
159,608 KB
testcase_31 AC 110 ms
159,696 KB
testcase_32 AC 118 ms
159,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string.h>
using namespace std;
long long int cs[10000001],cs2[10000001];
int main() {
	memset(cs,0,sizeof(cs));
	memset(cs2,0,sizeof(cs2));
	int n,d;
	cin>>n>>d;
	for(int x=1;x<=n;x++){
		for(int y=x;y<=n;y++){
			int t=x*x+y*y;
			cs[t]+=(x==y)?1:2;
			t=d+(x-y)*(x+y);
			if(0<t)cs2[t]++;
			if(x==y)continue;
			t=d+(y-x)*(x+y);
			if(t>0)cs2[t]++;
		}
	}
	long long int ans=0;
	for(int i=1;i<=10000000;i++){
		ans+=cs[i]*cs2[i];
	}
	cout<<ans<<endl;
	return 0;
}
0