题目链接
#include<bits/stdc++.h>
using namespace std;
int main()
{
int l,r;cin>>l>>r;
unordered_map<int,int> map;
int ans=0;
for(int y=0;y<=1000;y++)
{
for(int z=0;z<=1000;z++)
{
int x=y*y-z*z;
if(x>=l&&x<=r&&map[x]==0)
{
// cout<<x<<endl;
map[x]=1;
ans++;
}
}
}
cout<<ans<<endl;
return 0;
}
//这里的整数只考虑0以及正整数
import java.util.HashSet;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int L = scan.nextInt();
int R = scan.nextInt();
int ans = 0;
for (;L<=R;L++) {
if (L % 2 != 0 || L % 4 == 0) {
ans++;
}
}
System.out.println(ans);
}
}
# x = y^2 - z^2 = (y-z)(y+z) x和y-z和y+z奇偶相同
l,r = map(int,input().split())
ans = 0
# 当x为奇数,都可以满足
ans += (r+1)//2 - l//2
# 当x为偶数,需要是4的倍数
ans += r//4 - (l-1)//4
print(ans)