結果

問題 No.3493 等比数列の和の素因数
コンテスト
ユーザー yamate11
提出日時 2026-04-03 23:08:14
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 926 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,917 ms
コンパイル使用メモリ 330,432 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-03 23:08:31
合計ジャッジ時間 3,859 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <cassert>
using namespace std;
using ll = long long int;
using u64 = unsigned long long;
using pll = pair<ll, ll>;
// #include <atcoder/all>
// using namespace atcoder;
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define REPrev(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(coll) (coll).begin(), (coll).end()
#define SIZE(v) ((ll)((v).size()))
#define REPOUT(i, a, b, exp, sep) REP(i, (a), (b)) cout << (exp) << (i + 1 == (b) ? "" : (sep)); cout << "\n"

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  auto solve = [&]() -> bool {
    ll N, P; cin >> N >> P;
    if ((N + 1) % P == 0) return true;
    if (N == 0) return false;
    if (P == 2) return true;
    if (gcd(N + 1, P - 1) > 1) return true;
    return false;
  };
  cout << (solve() ? "Yes\n" : "No\n");

  return 0;
}

0