結果
問題 |
No.3233 順列判定
|
ユーザー |
|
提出日時 | 2025-08-15 23:02:35 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 1,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 3,062 ms |
コンパイル使用メモリ | 278,448 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-15 23:03:05 |
合計ジャッジ時間 | 4,342 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> namespace MyLib { constexpr uint_fast32_t pow_mod(uint_fast64_t a, uint_fast64_t b, const uint_fast32_t mod) noexcept { if (mod == 1) return 0; uint_fast32_t ans = 1; a %= mod; for (; b != 0; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } } static inline constexpr const char* solve(const uint_fast32_t N, const uint_fast32_t M) noexcept { std::vector<bool> is_appeared(N, false); for (uint_fast32_t i = 0; i != N; ++i) { const uint_fast32_t A = MyLib::pow_mod(i, M, N); if (is_appeared[A]) return "No"; is_appeared[A] = true; } return "Yes"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, M; std::cin >> N >> M; std::cout << solve(N, M) << '\n'; return 0; }