結果
問題 | No.1218 Something Like a Theorem |
ユーザー |
![]() |
提出日時 | 2020-09-04 21:33:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 2,387 ms |
コンパイル使用メモリ | 166,416 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 12:04:12 |
合計ジャッジ時間 | 2,135 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; ll powll(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base; base = base * base; exp >>= 1; } return res;} ll mod_pow(ll base,ll exp, ll mod) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base % mod; base = base * base % mod; exp >>= 1; } return res % mod;} int main() { int n, z; cin >> n >> z; if(n == 1) { cout << (z != 1 ? "Yes" : "No") << endl; return 0; } ll zs = powll(z, n); for(ll i = 1; i < z; i++) { for(ll j = i; j < z; j++) { ll xs = powll(i, n); ll ys = powll(j, n); if(xs + ys > zs)break; if(xs + ys == zs) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; }