結果

問題 No.800 四平方定理
ユーザー apoanzanapoanzan
提出日時 2019-03-17 22:47:22
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 869 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 151,468 KB
実行使用メモリ 85,196 KB
最終ジャッジ日時 2023-09-22 08:56:27
合計ジャッジ時間 8,331 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
5,264 KB
testcase_01 AC 32 ms
6,296 KB
testcase_02 AC 23 ms
5,360 KB
testcase_03 AC 24 ms
5,676 KB
testcase_04 AC 22 ms
5,240 KB
testcase_05 AC 24 ms
5,612 KB
testcase_06 AC 38 ms
6,896 KB
testcase_07 AC 29 ms
5,968 KB
testcase_08 AC 35 ms
7,012 KB
testcase_09 AC 33 ms
6,280 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 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){
			B[D-i*i+j*j]++;
		}
	}

	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