D. Buying Jewels

原题链接

题解

构造题,先想特殊情况再验证

易得当 n<k 时不成立

n=k 时输出 1

否则,第一个柜台卖的价格 p12

且最多能卖 np1+nmodp1 个,且最大值出现在 p1==2

(感性的理解)

code

#include<bits/stdc++.h>
#define ll long long
using namespace std;

void solve()
{
    ll n,k;

    cin>>n>>k;

    if(n==k)
    {
        cout<<"yes\n1\n"<<1<<'\n';
    }
    else if(2LL*(n-k+1LL)<=n)
    {
        cout<<"no\n";
    }
    else
    {
        cout<<"yes\n2\n";
        cout<<n-k+1LL<<' '<<1<<'\n';
    }
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}


posted @   纯粹的  阅读(12)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示