結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,068 KB
testcase_01 AC 3 ms
4,556 KB
testcase_02 AC 2 ms
4,340 KB
testcase_03 AC 3 ms
4,324 KB
testcase_04 AC 2 ms
4,164 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 3 ms
4,940 KB
testcase_07 AC 3 ms
4,600 KB
testcase_08 AC 3 ms
4,840 KB
testcase_09 AC 2 ms
4,748 KB
testcase_10 AC 53 ms
34,328 KB
testcase_11 AC 57 ms
38,224 KB
testcase_12 AC 56 ms
37,628 KB
testcase_13 AC 53 ms
35,912 KB
testcase_14 AC 57 ms
38,164 KB
testcase_15 AC 57 ms
38,040 KB
testcase_16 AC 57 ms
38,672 KB
testcase_17 AC 58 ms
38,544 KB
testcase_18 AC 58 ms
38,476 KB
testcase_19 AC 56 ms
38,576 KB
testcase_20 AC 2 ms
3,452 KB
testcase_21 AC 1 ms
3,392 KB
testcase_22 AC 60 ms
38,544 KB
testcase_23 AC 121 ms
65,988 KB
testcase_24 AC 116 ms
65,896 KB
testcase_25 AC 121 ms
65,712 KB
testcase_26 AC 1 ms
3,488 KB
testcase_27 AC 2 ms
3,452 KB
testcase_28 AC 113 ms
65,584 KB
testcase_29 AC 115 ms
65,880 KB
testcase_30 AC 116 ms
65,736 KB
testcase_31 AC 102 ms
61,368 KB
testcase_32 AC 116 ms
65,960 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