結果
問題 | No.1218 Something Like a Theorem |
ユーザー |
![]() |
提出日時 | 2020-09-11 03:11:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,110 bytes |
コンパイル時間 | 1,916 ms |
コンパイル使用メモリ | 195,864 KB |
最終ジャッジ日時 | 2025-01-14 09:26:02 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
#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";}