結果

問題 No.1218 Something Like a Theorem
ユーザー totori_nyaatotori_nyaa
提出日時 2020-09-11 03:11:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,110 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 201,612 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 21:26:40
合計ジャッジ時間 2,877 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n,z;
    cin>>n>>z;
    if(z == 1){
        cout << "No\n";
        return 0;
    }
    ll y = z;
    for(int i=1;i<n;i++)y*=z;
    if(n >= 20){
        cout << "NO\n";
        return 0;
    }
    if(n == 1){
        cout << "Yes\n";
        return 0;
    }
    bool pos = 1;
    vector<ll> st;
    for(ll i=1;i<100001;i++){
        ll now = 1;
        bool ok = false;
        for(int j=0;j<n;j++){
            now *= i;
            if(now > 1e6)ok = 1;
        }
        if(ok)break;
        st.push_back(now);
    }
    for(auto i:st){
        for(auto j:st){
            if(i+j == y){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";

}
0