結果

問題 No.800 四平方定理
ユーザー apoanzan
提出日時 2019-03-17 22:59:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 854 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 158,232 KB
実行使用メモリ 18,516 KB
最終ジャッジ日時 2024-07-08 01:39:32
合計ジャッジ時間 7,333 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 4 RE * 26
権限があれば一括ダウンロードができます

ソースコード

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

int B[4000005];
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