AB Game

Problem Statement

The following game is called Game nn:

The game is played by Alice and Bob. Initially, there are nn stones.

The players alternate turns, making a move described below, with Alice going first. The player who becomes unable to make a move loses.

  • In Alice's turn, she must remove a number of stones that is a positive multiple of AA.
  • In Bob's turn, he must remove a number of stones that is a positive multiple of BB.

In how many of Game 11, Game 22, ..., Game NN does Alice win when both players play optimally?

Constraints

  • 1 \leq N ,A,B \leq 10^{18}1≤N,A,B≤1018
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN AA BB

Output

Print the answer.

Sample 1

InputcopyOutputcopy
4 2 1
2

In Game 11, Alice cannot make a move and thus loses.

In Game 22, Alice removes 22 stones, and then Bob cannot make a move: Alice wins.

In Game 33, Alice removes 22 stones, Bob removes 11 stone, and then Alice cannot make a move and loses.

In Game 44, Alice removes 2 \times 2 = 42×2=4 stones, and then Bob cannot make a move: Alice wins.

Therefore, Alice wins in two of the four games.

Sample 2

InputcopyOutputcopy
27182818284 59045 23356
10752495144
#include <bits/stdc++.h>

#include <iostream>
using namespace std;
#define mm(a) memset(a, 0, sizeof(a))
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
const int MOD = 998244353;
typedef long long ll;
const ll MAX = 1e18 + 5;
const ll MIN = 1e9 + 5;
const int N = 2e5 + 5;




ll n, a, b;


int main() {
    // freopen("concatenation.in", "r", stdin);
    // freopen("concatenation.out", "w", stdout);
    cin >> n >> a >> b;
    ll t, k;
    ll sum = 0;
    if (n < a) 
    {
        printf("%lld\n", sum);
        return 0;
    }
    if (a <= b) {
        sum = n-a+1;
    }
    else 
    {
        t = n / a;
        k = n % a;
        if (k >= b)
        {
            sum += t * b;
        }
        else sum += (t-1) * b + k + 1;
    }
    cout << sum << endl;
    return 0;
}

headers = { "User-Agent": "Mozilla/5.0", "Accept-Language": "en-US,en;q=0.5", } #buff_cookie=Device-Id=XLjfIKmqYdZOl13kurAk; Locale-Supported=zh-Hans; game=csgo; NTES_YD_SESS=uRfvo1tg47qUhPC.zZn1eYfeulPZJ2LrgyFtvmT21FmVZ2qhZLps8NoRt2I6u42nBEfAl0DC2kr3Q0MJx1R_cgLha79FUaGziH_Ab0547Pp.m82.XHkIJ.cB9YRyjBJhrGvBgP8AcQAJKvnEU3mUbjNiZ_PWF5vhvnUMr1J95ljN8yzPU5DYCD7xRj4i3j3Z.LgtnCnAf44KDtYtOTI1CLIWZvkZ.tg_U_TZve0Q.WMMi; S_INFO=1686062063|0|0&60##|17860971786; P_INFO=17860971786|1686062063|1|netease_buff|00&99|null&null&null#not_found&null#10#0|&0||17860971786; remember_me=U1097288259|fSimYVO9MRMclOPjMhKxdzwo4KQ8Inz5; session=1-kTFVdNzCYMqOg0xjyicwy9GNHvKIN0dMQpwIFW2fVCbE2041173275; csrf_token=ImVmYzdiN2I0NTg5MGQyY2VlZDQwMGQxNzIxOTI1ZGIzNGE1MzI0Nzgi.F2DVgA.bHasgO17bW8V-MVkHAfrdjJDMuU buff_cookie="Device-Id=XLjfIKmqYdZOl13kurAk; Locale-Supported=zh-Hans; game=csgo; NTES_YD_SESS=uRfvo1tg47qUhPC.zZn1eYfeulPZJ2LrgyFtvmT21FmVZ2qhZLps8NoRt2I6u42nBEfAl0DC2kr3Q0MJx1R_cgLha79FUaGziH_Ab0547Pp.m82.XHkIJ.cB9YRyjBJhrGvBgP8AcQAJKvnEU3mUbjNiZ_PWF5vhvnUMr1J95ljN8yzPU5DYCD7xRj4i3j3Z.LgtnCnAf44KDtYtOTI1CLIWZvkZ.tg_U_TZve0Q.WMMi; S_INFO=1686062063|0|0&60##|17860971786; P_INFO=17860971786|1686062063|1|netease_buff|00&99|null&null&null#not_found&null#10#0|&0||17860971786; remember_me=U1097288259|fSimYVO9MRMclOPjMhKxdzwo4KQ8Inz5; session=1-kTFVdNzCYMqOg0xjyicwy9GNHvKIN0dMQpwIFW2fVCbE2041173275; csrf_token=ImVmYzdiN2I0NTg5MGQyY2VlZDQwMGQxNzIxOTI1ZGIzNGE1MzI0Nzgi.F2DVgA.bHasgO17bW8V-MVkHAfrdjJDMuU" headers['Cookie'] = buff_cookie base_url="https://buff.163.com/api/market/goods/sell_order?game=csgo&goods_id=%goods_id%&page_num=1" goods_id=35245 base_url= base_url.replace('%goods_id%',str(goods_id)) print(base_url)
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值