为什么 CF 上的输出和本地不一样啊
  • 板块学术版
  • 楼主VenusM1nT
  • 当前回复6
  • 已保存回复6
  • 发布时间2020/11/20 20:13
  • 上次更新2023/11/5 07:39:36
查看原帖
为什么 CF 上的输出和本地不一样啊
23243
VenusM1nT楼主2020/11/20 20:13
#include<bits/stdc++.h>
#define N 100
#define reg register
#define inl inline
#define int long long
#define inf 1e18
using namespace std;
int Q;
vector <int> g;
inl int Pow(reg int x,reg int y)
{
	reg int res=1;
	for(;y;y>>=1,x=x*x) if(y&1) res=res*x;
	return res;
}
inl void Init()
{
	for(reg int i=3;i<=59;i+=2)
	{
		for(reg int j=1;j<=1000000;j++)
		{
			reg int cnt=Pow(j,i);
			if(!cnt || cnt==1 || (int)sqrt(cnt)*(int)sqrt(cnt)==cnt) continue;
			if(cnt>inf || cnt<0) break;
			g.push_back(cnt);
		}
	}
	sort(g.begin(),g.end());
	g.erase(unique(g.begin(),g.end()),g.end());
}
inl int Calc(reg int n)
{
	reg int res=(int)sqrt(n);
	reg int pos=lower_bound(g.begin(),g.end(),n)-g.begin();
	if(pos<(int)g.size() && g[pos]>n) pos--;
	res+=pos;
	return res;
}
signed main()
{
	ios::sync_with_stdio(0);
	Init();
	cin>>Q;
	while(Q--)
	{
		reg int l,r;
		cin>>l>>r;
		cout<<Calc(r)-Calc(l-1)<<endl;
	}
	return 0;
}

题目是 CF955C,数据是

1
387291074607832779 798305191127761550

输出是

271351299

但是在 CF 上的输出是

271351340

怪事

2020/11/20 20:13
加载中...