题解:CF2166B Tab Closing

· · 题解

思路

我们发现,标签页并没有挤满时,我们将鼠标放在开头一直叉即可,要 1 次,否则我们先将鼠标放在最后叉到没有满为止再去开头叉,要 2 次。

注意如果 a=b,我们从最后一直叉也能叉完,只要 1 次。

代码

#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,a,b,n; 
signed main(){
    cin>>T;
    for(int i=1;i<=T;i++){
        cin>>a>>b>>n;
        if(a<b*n&&a!=b)
            cout<<2<<endl;
        else
            cout<<1<<endl;
    }
    return 0;
}