11 Joyboard

Joyboard 打表

image
image
image
image
image

题目数据给的很夸张,单纯的模拟肯定不行,直接打表找出规律!

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    ll n, m, k;
    cin >> n >> m >> k;
    if (k == 1)
    {
        cout << 1 << "\n"; // 只有0一种
        return;
    }
    if (k > 3)
    {
        cout << 0 << endl;
        return;
    }
    if (m <= n)
    {
        if (k == 2)
        {
            cout << m << endl; // 除去0
            return;
        }
        else
        {
            cout << 0 << endl;
            return;
        }
    }
    else
    {
        ll sum = n - 1;
        sum += m / n;
        if (k == 2)
        {
            cout << sum << '\n';
        }
        else
        {
            cout << m - sum << '\n';
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
posted @ 2024-01-18 19:28  yufan1102  阅读(3)  评论(0编辑  收藏  举报