11 Joyboard
Joyboard 打表
题目数据给的很夸张,单纯的模拟肯定不行,直接打表找出规律!
#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;
}