Pagini recente » Cod sursa (job #2223003) | Cod sursa (job #2532414) | Cod sursa (job #2018591) | Cod sursa (job #2010768) | Cod sursa (job #2023282)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2;
const long long INF = 1e16;
long long fib[MAXN] = {1, 1};
int main()
{
int f = 1, q;
long long x1, y1, x2, y2;
while (fib[f] < INF) {
++f;
fib[f] = fib[f - 1] + fib[f - 2];
}
ifstream fin("fibo3.in");
fin >> q;
ofstream fout("fibo3.out");
for (q = q; q > 0; --q) {
fin >> x1 >> y1 >> x2 >> y2;
long long ans = 0LL;
for (int i = 1; i <= f; ++i)
if (x1 + y1 <= fib[i] && fib[i] <= x2 + y2) {
long long a = max(fib[i] - x2, y1), b = min(fib[i] - x1, y2);
ans += b - a + 1;
}
fout << ans << '\n';
}
fin.close();
fout.close();
return 0;
}