結果

問題 No.1218 Something Like a Theorem
ユーザー 👑 CleyL
提出日時 2022-07-09 00:32:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 74,988 KB
最終ジャッジ日時 2025-01-30 05:44:46
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
using namespace std;
int main(){
    int n,z;cin>>n>>z;
    if(n >= 3){
        cout << "No" << endl;
    }else if(n == 2){
        set<int> x;
        for(int i = 1; z*z >= i*i; i++){
            x.insert(i*i);
        }
        for(int i = 1; z*z >= i*i; i++){
            if(x.count(z*z-i*i)){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }else if(z >= 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}
0