数学题,做过类似的,但是还是没写出来.. 首先把x写成分解因式的形式,发现x的两个因柿必须奇偶性一样~
然后奇数的话可以拆分成1和它本身,偶数的话你要拆分成两个偶数因此必须是4的倍数的偶数才能拆分然后你把符合条件的都加起来就好了
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
const int N = 1e5+10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
int l,r;
int cal1(int x){
return (x+1)/2;
}
int cal2(int x){
return x/4;
}
void solve()
{
cin>>l>>r;
cout<<cal1(r)-cal1(l-1)+cal2(r)-cal2(l-1);
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int _;
//cin>>_;
_ = 1;
while(_--)solve();
return 0;
}