結果

問題 No.1218 Something Like a Theorem
ユーザー 沙耶花
提出日時 2020-09-04 21:24:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 194,140 KB
最終ジャッジ日時 2025-01-14 04:55:38
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000	

int main(){

	int n,z;
	cin>>n>>z;
	
	if(n>=3){
		cout<<"No"<<endl;
		return 0;
	}
	
	if(n==1){
		if(z==1)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
		return 0;
	}
	
	vector<bool> S(1000005,false);
	for(int i=1;i<=1000;i++){
		S[i*i]=true;
	}
	
	for(int i=1;i<=1000000;i++){
		int X = z*z-i;
		if(X<0)continue;
		if(S[i]&&S[X]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
	
	return 0;
}
0