题解:P11204 「Cfz Round 9」Lone

首先可以观察出把木棍平均分是最优的。

然后平均分后最多只有两种长度的木棒,长度分别为 \(\lfloor \frac{m}{n} \rfloor\)\(\lfloor \frac{m}{n} \rfloor + 1\)

最后 check 一下就行了。

代码:

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define flush() fwrite(obuf,1,O-obuf,stdout)
#define putchar(x) ((O==obuf+(1<<21))&&(flush(),O=obuf)),*O++=x
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read() {
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
    return x*f;
}
inline void write(register int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar((x%10)^48);
}
struct Flush{
    ~Flush(){flush();}
}_;
signed main(){
    int t,n,m;
    cin>>t;
    while(t--){
        cin>>n>>m;
        bool f=1;
        int s1=m%n,s2=n-m%n;
        int len1=m/n+1,len2=m/n;
        if(s1==0){
            cout<<"Yes\n";
        }
        else{
            if(s1>1){
                if(len2+len1<=len1){
                    f=0;
                }
            }
            if(s2>1){
                if(len2+len2<=len1){
                    f=0;
                }
            }
            if(!f){
                cout<<"No\n";
            }
            else{
                cout<<"Yes\n";
            }
        }
    }
    return 0;
}
posted @ 2024-10-22 20:52  CJZJC  阅读(10)  评论(0编辑  收藏  举报