50分WA求调
  • 板块P11184 带余除法
  • 楼主myz123
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/10/13 18:21
  • 上次更新2024/10/13 20:00:38
查看原帖
50分WA求调
766167
myz123楼主2024/10/13 18:21
#include<bits/stdc++.h>
using namespace std;
int t;
long long a,b; 
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	{
		cin>>a>>b;
		if(b==0||a==b)
		{
			cout<<1<<"\n";
			continue;
		}
		long long l=1,r=a;
		while(l<=r)
		{
			
			long long mid=(l+r)/2;
//			cout<<mid<<" ";
			if((a-mid*b)<mid)
			{
				r=mid-1;
			}
			else
			{
				l=mid+1;
			}
		}
		long long ansl=l;
		l=1,r=a;
		while(l<=r)
		{
			long long mid=(l+r)/2;
			if(b*mid<=a)
			{
				l=mid+1; 
			}
			else
			{
				r=mid-1;
			}
		}
		cout<<r-ansl+1<<"\n";
	}
	return 0;
}

真服了,这个第一题难度远远大于第二题,还不知道怎么做

2024/10/13 18:21
加载中...