結果

問題 No.800 四平方定理
ユーザー kaagekaage
提出日時 2019-03-17 22:05:09
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 641 bytes
コンパイル時間 1,303 ms
コンパイル使用メモリ 155,484 KB
実行使用メモリ 71,064 KB
最終ジャッジ日時 2023-09-22 06:27:10
合計ジャッジ時間 6,204 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
5,236 KB
testcase_01 AC 34 ms
6,128 KB
testcase_02 AC 24 ms
5,336 KB
testcase_03 AC 26 ms
5,528 KB
testcase_04 AC 22 ms
5,176 KB
testcase_05 AC 27 ms
5,544 KB
testcase_06 AC 42 ms
6,640 KB
testcase_07 AC 33 ms
5,792 KB
testcase_08 AC 36 ms
6,608 KB
testcase_09 AC 37 ms
6,176 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
int n,d;
set<int> st;
map<int,int> mp;
signed main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			mp[i*i+j*j]++;
			st.insert(i*i+j*j);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(st.find(i*i-j*j+d)!=st.end())ans+=mp[i*i-j*j+d];
		}
	}
	cout<<ans<<endl;
	return 0;
}
0