Hướng dẫn giải của Quảng cáo


Chỉ dùng lời giải này khi không có ý tưởng, và đừng copy-paste code từ lời giải này. Hãy tôn trọng người ra đề và người viết lời giải.
Nộp một lời giải chính thức trước khi tự giải là một hành động có thể bị ban.
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define mp make_pair
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;

const int Thanh_Tam = 1e5+17;
const int inf = 1e9 + 17;
const int mod = 1e9 + 7;
const int Log = 17;

void ThanhTam()
{
    ll m,a,b;
    cin >> m >> a >> b;
    if (m < a)
        cout << "0\n";
    else
    cout << (((m-a)/b)*a)+a-1 << "\n";

    return;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    if (fopen("QUANGCAO.inp","r"))
    {
        freopen("QUANGCAO.inp","r",stdin);
        freopen("QUANGCAO.out","w",stdout);
    }

    int t;
    cin >> t;
    while (t--)
        ThanhTam();

    return 0;
}

Loading...