D. Buying Jewels
题解
构造题,先想特殊情况再验证
易得当 \(n<k\) 时不成立
当 \(n=k\) 时输出 1
否则,第一个柜台卖的价格 \(p_1 \geq 2\)
且最多能卖 \(\lfloor\frac{n}{p_1} \rfloor + n\mod p_1\) 个,且最大值出现在 \(p_1==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;
}

浙公网安备 33010602011771号