結果

問題 No.800 四平方定理
ユーザー apoanzanapoanzan
提出日時 2019-03-17 22:44:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 915 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 155,344 KB
実行使用メモリ 82,100 KB
最終ジャッジ日時 2023-09-22 08:48:17
合計ジャッジ時間 7,067 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
4,892 KB
testcase_01 AC 39 ms
6,360 KB
testcase_02 AC 27 ms
5,248 KB
testcase_03 AC 30 ms
5,916 KB
testcase_04 AC 25 ms
5,328 KB
testcase_05 AC 29 ms
5,516 KB
testcase_06 AC 49 ms
7,076 KB
testcase_07 AC 35 ms
6,056 KB
testcase_08 AC 44 ms
7,280 KB
testcase_09 AC 41 ms
6,332 KB
testcase_10 TLE -
testcase_11 -- -
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>
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];
			}*/
			if(B[i*i+j*j]>=1) cnt+= B[i*i+j*j];
		}
	}
	cout << cnt <<endl;
	return 0;
}
0