Codeforces Round 902 (Div. 2) C. Joyboard
//思路:在k=1,k=2,k=3 时有解
//当 k=1 时为全0
//当 k=2 时,若 m>=n,则先是 0 然后为 1~n,最后一位可以为n的倍数也符合,即n+m/n-1
//若m<n则为 1~m 即 m
//当 k=3 时,只能在n+1位是第3个不同情况(大于n),且不能为n的倍数,即 (m-n)-(m/n-1)
//只在m>n时k=3有解
#define int long long
#define ld long double
using namespace std;
int t;
void op()
{
int n, m, k;
cin >> n >> m >> k;
if (k > 3)cout << 0 << endl;
else if (k == 1)
{
cout << 1 << endl;
}
else if (k == 2)
{
int f = m / n;
if (m >= n)
{
cout << n + f - 1 << endl;
}
else
{
cout << m << endl;
}
}
else if (k == 3)
{
int f = m / n;
if (m > n)
{
cout << m - (n - 1) - f << endl;
}
else cout << 0 << endl;
}
}
signed main()
{
cin >> t;
while (t--)
{
op();
}
return 0;
}
标签:902,cout,int,Joyboard,Codeforces,long,Div
From: https://www.cnblogs.com/ikunhuaji/p/17753941.html