HDU4279(数论)

#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
#define maxn 5111
const double INF = (1<<31);

long double l, r;

long long solve (long double x) {
    if (x < 6)
        return 0;
    long long ans = x/2 + (((long long)sqrt (1.0*x))%2 == 1 ? -1 : -2);
    return ans;
}

int main () {
    int t;
    cin >>t;
    while (t--) {
        cin >> l >> r;
        if (l > r)
        while (1) {}
        cout << solve (r) - solve (l-1) << endl;
    }
    return 0;
}

你可能感兴趣的:(HDU4279(数论))