結果

問題 No.800 四平方定理
ユーザー ark27ark27
提出日時 2019-07-26 11:40:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 165,316 KB
実行使用メモリ 128,616 KB
最終ジャッジ日時 2023-09-15 00:15:43
合計ジャッジ時間 6,498 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
128,388 KB
testcase_01 AC 47 ms
128,604 KB
testcase_02 AC 46 ms
128,552 KB
testcase_03 AC 46 ms
128,440 KB
testcase_04 AC 46 ms
128,396 KB
testcase_05 AC 47 ms
128,344 KB
testcase_06 AC 47 ms
128,324 KB
testcase_07 AC 47 ms
128,484 KB
testcase_08 AC 47 ms
128,396 KB
testcase_09 AC 47 ms
128,480 KB
testcase_10 AC 82 ms
128,344 KB
testcase_11 AC 84 ms
128,328 KB
testcase_12 AC 86 ms
128,484 KB
testcase_13 AC 75 ms
128,336 KB
testcase_14 AC 80 ms
128,488 KB
testcase_15 AC 86 ms
128,316 KB
testcase_16 AC 80 ms
128,616 KB
testcase_17 AC 80 ms
128,344 KB
testcase_18 AC 90 ms
128,476 KB
testcase_19 AC 89 ms
128,320 KB
testcase_20 AC 46 ms
128,408 KB
testcase_21 AC 46 ms
128,408 KB
testcase_22 AC 89 ms
128,320 KB
testcase_23 AC 128 ms
128,324 KB
testcase_24 AC 116 ms
128,320 KB
testcase_25 AC 128 ms
128,412 KB
testcase_26 AC 44 ms
128,348 KB
testcase_27 AC 46 ms
128,324 KB
testcase_28 AC 116 ms
128,360 KB
testcase_29 AC 126 ms
128,320 KB
testcase_30 AC 114 ms
128,372 KB
testcase_31 AC 109 ms
128,360 KB
testcase_32 AC 115 ms
128,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

int main(){
	ll n,d;
	cin >> n >> d;
	ll c1[8000010],c2[8000010];
	FOR(i,8000005){
		c1[i]=0;
		c2[i]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			c1[i*i+j*j]++;
			if(i*i-j*j+d<0)continue;
			c2[i*i-j*j+d]++;
		}
	}
	ll ans=0;
	for(int i=1;i<=8000005;i++){
		ans+=c1[i]*c2[i];
	}
	cout << ans << endl;
}
0