一、视频讲解
蓝桥杯真题讲解:平方差 (打表+数学)
二、正解代码
#include<bits/stdc++.h>
#define endl '\n'
#define deb(x) cout << #x << " = " << x << '\n';
#define INF 0x3f3f3f3f
using namespace std;
void test(){
map<int,int>st;
for(int i = 1; i <= 100; i ++){
for(int j = 0; j <= 100; j ++){
for(int k = 0; k <= 100; k ++){
if(i == (j * j - k * k)){
if(i % 2)continue;
if(!st[i])
cout << i << endl;
st[i] = true;
}
}
}
}
}
void solve()
{
int l, r;
cin >> l >> r;
int sr = (r + 1) / 2 + r / 4;
int sl = (l - 1 + 1) / 2 + (l - 1) / 4;
cout << sr - sl << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
while(t--)
solve();
}