結果

問題 No.800 四平方定理
ユーザー okok
提出日時 2019-03-17 22:35:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 971 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 70,832 KB
実行使用メモリ 66,136 KB
最終ジャッジ日時 2023-09-22 08:22:49
合計ジャッジ時間 2,688 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,524 KB
testcase_01 AC 3 ms
5,472 KB
testcase_02 AC 2 ms
5,408 KB
testcase_03 AC 2 ms
5,460 KB
testcase_04 AC 2 ms
5,532 KB
testcase_05 AC 2 ms
5,400 KB
testcase_06 AC 2 ms
5,676 KB
testcase_07 AC 2 ms
5,468 KB
testcase_08 AC 2 ms
5,476 KB
testcase_09 AC 3 ms
5,404 KB
testcase_10 AC 26 ms
36,192 KB
testcase_11 AC 28 ms
40,420 KB
testcase_12 AC 30 ms
38,176 KB
testcase_13 AC 31 ms
38,228 KB
testcase_14 AC 30 ms
40,284 KB
testcase_15 AC 32 ms
40,228 KB
testcase_16 AC 30 ms
40,224 KB
testcase_17 AC 34 ms
40,420 KB
testcase_18 AC 31 ms
40,276 KB
testcase_19 AC 32 ms
40,276 KB
testcase_20 AC 2 ms
5,396 KB
testcase_21 AC 2 ms
5,424 KB
testcase_22 AC 34 ms
40,540 KB
testcase_23 AC 63 ms
66,060 KB
testcase_24 AC 66 ms
66,048 KB
testcase_25 AC 70 ms
66,016 KB
testcase_26 AC 2 ms
5,464 KB
testcase_27 AC 2 ms
5,468 KB
testcase_28 AC 54 ms
65,952 KB
testcase_29 AC 59 ms
65,996 KB
testcase_30 AC 59 ms
66,136 KB
testcase_31 AC 55 ms
62,748 KB
testcase_32 AC 62 ms
66,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 4100000

int temp[MAX*2];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, D, count = 0;
	
	cin>>N>>D;
	
	
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			// cout<<j*j-i*i<<" ++ "<<endl;
			temp[j*j-i*i+MAX]++;
		}
	}
	
	
	for(int i = 1; i <= N; i++){
		for(int j = i; j <= N; j++){
			int t = i*i+j*j-D;
			// cout<<t<<endl;
			if(t+MAX < 0 || t+MAX >= MAX*2) continue;
			if(temp[t+MAX]){
				// cout<<i<<" "<<j<<" "<<temp[t+MAX]<<endl;
				if(i == j)count += temp[t+MAX];
				else count += temp[t+MAX]*2;
			}
		}
	}
	
	cout<<count<<endl;
	
	return 0;
}
0