結果

問題 No.800 四平方定理
ユーザー okok
提出日時 2019-03-17 22:32:57
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 926 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 70,524 KB
実行使用メモリ 66,128 KB
最終ジャッジ日時 2023-09-22 08:15:12
合計ジャッジ時間 6,998 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,392 KB
testcase_01 AC 3 ms
5,648 KB
testcase_02 AC 2 ms
5,408 KB
testcase_03 AC 2 ms
5,380 KB
testcase_04 AC 2 ms
5,384 KB
testcase_05 AC 2 ms
5,384 KB
testcase_06 AC 2 ms
5,656 KB
testcase_07 AC 2 ms
5,400 KB
testcase_08 AC 3 ms
5,464 KB
testcase_09 AC 2 ms
5,672 KB
testcase_10 AC 26 ms
36,100 KB
testcase_11 RE -
testcase_12 AC 49 ms
38,432 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 51 ms
40,404 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 50 ms
40,444 KB
testcase_19 AC 47 ms
40,204 KB
testcase_20 AC 2 ms
5,676 KB
testcase_21 AC 2 ms
5,656 KB
testcase_22 AC 53 ms
40,204 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
5,400 KB
testcase_27 AC 3 ms
5,456 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

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(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