题意:若n满足求和 (k从1-n)[n/k] 结果是偶数,则n称为xx数
给定a,b 问区间内是xx数的有多少个 ([]是取整符号)
数论不大好,就直接找规律做了
#include<stdio.h>
#include<set>
#include<math.h>
using namespace std;
#define N 10000000
#define F(x) 2*x*x-x//F(0)=0
#define ll long long
#define maxx 9223372036854775807
ll sec(ll x){return 2*(sqrt((double)x));}
ll Ans(ll x){
if(x==-1)return 0;
ll k=(x/4); k=sqrt((double)k);
ll ans=F(k);
ll z=k*4;
if(x>k*k*4+z)ans+=z+1;
else ans+=x-k*k*4+1;
return ans;
}
int main()
{
ll a,b;
while(~scanf("%lld%lld",&a,&b))
printf("%lld\n",Ans(b)-Ans(a-1));
return 0;
}/*
bool can(int x){//打表代码
int ans=0,i;
for(i=1;i<=x;i++)
ans+=x/i;
return ans&1;
}
int main()
{
ll i,j=4,k;
for(i=0;i<N;i++)
if(!can(i))
printf("%d\n",i);
return 0;
}
*/