Cod sursa(job #1038762)

Utilizator gerd13David Gergely gerd13 Data 21 noiembrie 2013 22:36:26
Problema Fibo3 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
# include <fstream>
# define MAXN 110

using namespace std;

long long N, x1, x2, y1, y2, sol, a[MAXN];

ifstream cin ("fibo3.in");
ofstream cout ("fibo3.out");

int main()
{
    cin >> N ;

    a[1] = a[2] = 1 ;

    for ( ; N; -- N)
    {
        sol = 0 ;
        cin >> x1 >> y1 >> x2 >> y2 ;
            for ( int i = 2; i <= 100; ++ i) {
                if(a[i] <  x1 + y1)
                    continue ;
                if ( a[i] > x2 + y2)
                    break ;

        sol += min (x2, a[i] - y1) - max ( x1, a[i] - y2)  +1 ;

                }
                cout << sol;
    }


    cin.close();
    cout.close();
    return 0;
}