結果

問題 No.3112 Decrement or Mod Game
ユーザー tomo8
提出日時 2025-04-19 00:28:59
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 3,368 bytes
コンパイル時間 3,294 ms
コンパイル使用メモリ 274,684 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-19 00:29:04
合計ジャッジ時間 5,368 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef MAIN
#define MAIN
#include __FILE__

//using mint = modint998244353;

void _main(){
  cint(a, b);
  bool f = true;
  while (1) {
    if (!a) break;
    if (!b) {
      f = 0; break;
    }
    // Alice's turn
    if (a < b) {
      --a;
      if (!a) break;
    }
    else {
      if (a - b <= b) {
        cout << "Alice" << endl;
        return;
      } 
      a %= b;
      if (!a) break;
    }
    //cerr << "Alice: " << a << endl;
    // Bob's turn
    if (a > b) {
      --b;
      if (!b) {
        f = 0; break;
      }
    }
    else {
      if (b - a <= a) {
        cout << "Bob" << endl;
        return;
      } 
      b %= a;
      if (!b) {
        f = 0; break;
      }
    }
    //cerr << "  Bob: " << b << endl;
  }
  cout << (f ? "Alice" : "Bob") << endl;
}

#else
#define MAIN

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using strvec = vector<string>;

constexpr ll mod10 = 1000000007;
constexpr ll mod9 = 998244353;
constexpr ll inf = 10000000000000000;

#define int ll
#define double ld
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repf(i, s, n) for (int i = s; i < (int)(n); i++)
template <class... Args>
void __y_input(Args &...arg)
{
    (cin >> ... >> arg);
}

template <class... Args>
void __y_input_vec_1(int p, Args &...args)
{
    (cin >> ... >> args[p]);
}
template <class Arg>
void __y_input_vec_resize(int size, Arg &arg)
{
    arg.resize(size);
}
template <class... Args>
void __y_input_vec(int n, Args &...args)
{
    (__y_input_vec_resize(n, args), ...);
    rep(i, n)
    {
        (__y_input_vec_1(i, args), ...);
    }
}
#define cint(...)  \
    int __VA_ARGS__; \
    __y_input(__VA_ARGS__)

#define cdbl(...)     \
    double __VA_ARGS__; \
    __y_input(__VA_ARGS__)

#define cstr(...)     \
    string __VA_ARGS__; \
    __y_input(__VA_ARGS__)

#define cvec(n, ...)       \
    vector<int> __VA_ARGS__; \
    __y_input_vec(n, __VA_ARGS__)

#define cvect(t, n, ...) \
    vector<t> __VA_ARGS__; \
    __y_input_vec(n, __VA_ARGS__)

#define last cout << endl
#define yn(bl) (bl ? "Yes" : "No")
#define all(v) v.begin(), v.end()
#define acc(v) accumulate(v.begin(), v.end(), 0LL)
#define nxp(v) next_permutation(v.begin(), v.end())
ostream &yesno(bool bl)
{
    cout << yn(bl);
    return cout;
}
void cyn(bool bl){
    cout << (bl ? "Yes" : "No") << endl;
}
typedef array<int, 2> xy;
typedef array<int, 3> xyz;

template <typename T>
inline void sort(T &vec)
{
    return sort(vec.begin(), vec.end());
}
template <typename T>
inline void rsort(T &vec)
{
    return sort(vec.rbegin(), vec.rend());
}
void _main();

template <typename T>
void prefix_sum(vector<T>& p, vector<T>& s){
  s.emplace_back(p[0]);
  for (size_t i = 1; i < p.size(); i++){
    s.emplace_back(p[i] + s.back());
  }
  return;
}

template <typename T>
void compress(T a, T b){
  vector m(a, b);
  sort(all(m));
  m.erase(unique(all(m)), m.end());
  for (auto itr = a; itr != b; itr++){
    *itr = (lower_bound(all(m), *itr) - m.begin());
  }
}

template <typename T>
using rpq = priority_queue<T, vector<T>, greater<T>>;

template <class T>
void operator+=(vector<T>& v, const T t) {
  v.emplace_back(t);
}

signed main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    _main();
    return 0;
}

#endif
0