Cod sursa(job #2616430)
Utilizator | Mujdar Milan mjmilan11 | Data | 18 mai 2020 15:08:28 |
---|---|---|---|
Problema | Fibo3 | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fibo3.in");
ofstream fout("fibo3.out");
const int NMAX = 75;
long long f[80];
long long n,x1,x2,igrec1,y2,rasp;
int main()
{
f[0]=f[1]=1;
for(int i=2;i<=NMAX;i++) f[i]=f[i-1]+f[i-2];
fin >> n;
for(int i=1;i<=n;i++){
fin >> x1 >> igrec1 >> x2 >> y2;
rasp=0;
for(int j=1;j<=NMAX;j++){
if(x1+igrec1<=f[j] and f[j]<=x2+y2){
rasp=rasp+min(x2,f[j]-igrec1)-max(x1,f[j]-y2)+1;
}
}
fout << rasp << '\n';
}
return 0;
}