結果

問題 No.800 四平方定理
ユーザー apoanzanapoanzan
提出日時 2019-03-17 22:41:52
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 876 bytes
コンパイル時間 1,304 ms
コンパイル使用メモリ 156,236 KB
実行使用メモリ 70,456 KB
最終ジャッジ日時 2023-09-22 08:44:02
合計ジャッジ時間 28,289 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
4,516 KB
testcase_01 AC 30 ms
5,316 KB
testcase_02 AC 23 ms
4,740 KB
testcase_03 AC 23 ms
5,024 KB
testcase_04 AC 21 ms
4,728 KB
testcase_05 AC 25 ms
4,848 KB
testcase_06 AC 35 ms
5,764 KB
testcase_07 AC 26 ms
5,376 KB
testcase_08 AC 27 ms
5,680 KB
testcase_09 AC 33 ms
5,552 KB
testcase_10 AC 1,843 ms
57,772 KB
testcase_11 AC 1,827 ms
69,796 KB
testcase_12 TLE -
testcase_13 AC 1,906 ms
60,396 KB
testcase_14 AC 1,882 ms
69,440 KB
testcase_15 TLE -
testcase_16 AC 1,860 ms
69,184 KB
testcase_17 AC 1,927 ms
70,276 KB
testcase_18 TLE -
testcase_19 AC 1,987 ms
69,672 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

map<int,int> B;
vector<int> A;
int ans,cnt;
int main(){
	int N,D;
	cin >> N >> D;
	for(int i = 1;i<N+1;++i){
		for(int j = 1;j<N+1;++j){
			A.pb(D-i*i+j*j);
			B[D-i*i+j*j]++;
		}
	}
	sort(A.begin(),A.end());

	for(int i = 1;i <N+1;++i){
		for(int j=1;j<N+1;++j){
			if(binary_search(A.begin(),A.end(),i*i+j*j)){
			/*	cout <<"upp: " <<*upper_bound(A.begin(),A.end(),i*i+j*j)<<endl;
				cout <<"low: " <<*lower_bound(A.begin(),A.end(),i*i+j*j)<<endl;
				ans += *upper_bound(A.begin(),A.end(),i*i+j*j)-*lower_bound(A.begin(),A.end(),i*i+j*j)+1;*/
				if(B[i*i+j*j]>=1) cnt += B[i*i+j*j];
			}
		}
	}
	cout << cnt <<endl;
	return 0;
}
0