90分,怎么卡都过不了
  • 板块P1582 倒水
  • 楼主zzb1217
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/9/21 08:37
  • 上次更新2023/11/2 18:55:11
查看原帖
90分,怎么卡都过不了
746761
zzb1217楼主2023/9/21 08:37
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int ok(int n)
{
	int ans=0;
	while (n>0)
	{
		n-=(n&-n);
		ans++;
	}
	return ans;
}
signed main()
{
	int n,m,ans=0;
	scanf("%lld%lld",&n,&m);
	while (ok(n)>m)
	{
		ans++;
		n++;
	}
	printf("%lld",ans);
}
2023/9/21 08:37
加载中...