Pagini recente » Cod sursa (job #1809152) | Cod sursa (job #2509739) | Cod sursa (job #2493608) | Cod sursa (job #409094) | Cod sursa (job #466515)
Cod sursa(job #466515)
#include <stdio.h>
using namespace std;
long long f_curent, f1, f2;
long long x1, y1, x2, y2;
long long i, j, k;
long int puncte, n;
int main ()
{
FILE *f = fopen ("fibo3.in","r");
FILE *g = fopen ("fibo3.out","w");
fscanf (f,"%ld", &n);
for (k=1; k<=n; ++k)
{
fscanf (f,"%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
puncte = 0;
f_curent = 0;
f1 = f2 = 1;
for (i=x1; i<=x2; ++i)
{
for (j=y1; j<=y2; ++j)
{
f_curent = 0;
f1 = f2 = 1;
while (f_curent < i + j)
{
f_curent = f1 + f2;
f1 = f2;
f2 = f_curent;
}
if (f_curent == i + j)
{
//printf ("%d \n", i + j);
puncte ++;
}
}
}
fprintf (g,"%ld\n", puncte);
}
fclose(g);
fclose(f);
return 0;
}