Cod sursa(job #466515)

Utilizator miculprogramatorA Cosmina - vechi miculprogramator Data 26 iunie 2010 21:12:47
Problema Fibo3 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.04 kb
#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;
}