結果
| 問題 |
No.1218 Something Like a Theorem
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-09-04 21:25:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 587 bytes |
| コンパイル時間 | 3,046 ms |
| コンパイル使用メモリ | 248,248 KB |
| 最終ジャッジ日時 | 2025-01-14 04:58:20 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#include <bits/extc++.h>
template <class T, class Op = std::multiplies<>>
constexpr T power(T a, uint64_t n, T init = 1, Op op = Op{}) {
while (n) {
if (n & 1) init = op(init, a);
if (n >>= 1) a = op(a, a);
}
return init;
}
int main() {
using namespace std;
cin.tie(nullptr)->sync_with_stdio(false);
int n, z;
cin >> n >> z;
vector<int> v;
for (int x = 1; x < z; ++x) v.push_back(power(x, n));
for (int x : v) {
int yn = power(z, n) - x;
if (binary_search(begin(v), end(v), yn)) {
cout << "Yes\n";
exit(0);
}
}
cout << "No\n";
}
risujiroh