社区讨论

ABC D AC*6WA*4求调

学术版参与者 9已保存回复 12

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
12 条
当前快照
1 份
快照标识符
@mhj11z4l
此快照首次捕获于
2025/11/03 18:58
4 个月前
此快照最后确认于
2025/11/03 20:32
4 个月前
查看原帖
CPP
#include <iostream>
#include <cmath>
#define int long long
using namespace std;
int t,a,b;
signed main()
{
	cin >> t;
	while(t --)
	{
		cin >> a >> b;
		int p = 0,q = 0,len = 0,Len = 0,ans = 0;
		b += a;
		string s = to_string(a);
		string S = s,S2 = s;
		string T2 = to_string(a +1);
		string t = to_string(b);
		s = s + t,S2 = S2 + T2;
		for(int i = 0;i < S2.size();i ++)p = p * 10 + S2[i] - 48;
		for(int i = 0;i < s.size();i ++)q = q * 10 + s[i] - 48;
		Len = S2.size(),len = s.size();
		for(int i = Len;i <= len;i ++)
		{
			int hah = 1;
			for(int j = 1;j <= i - (int)S.size();j ++)hah *= 10;
			int ea = ceil(sqrt(max(p,a * hah))),eb = floor(sqrt(min(q,a * hah + hah - 1)));
			while(ea <= eb && ea * ea - a * hah < hah / 10)ea ++;
			if(ea > eb)continue ;
			ans = ans + (eb - ea + 1);
		}
		cout << ans << '\n';
	}
}

回复

12 条回复,欢迎继续交流。

正在加载回复...