- 2023tyoi0292 的博客
卡牌
- 2024-7-5 22:09:50 @
卡牌
思路:透过出题人的描述得出形式化题:在[l,r]中找一个x,使其满足
由平方差公式得出:
所以要找的x可以分解为两个同奇或同偶的因数
在一顿打表后得出x为4的倍数或奇数可以满足条件
AC code:
//2023tyoi0292
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
int main() {
ll t;
cin >> t;
while(t--) {
ll l, r;
cin >> l >> r;
cout << r / 4 - (l - 1) / 4 + (r + 1) / 2 - l / 2 << endl;
}
return 零;
}