Cod sursa(job #797951)

Utilizator stanescumalinStanescu Malin Octavian stanescumalin Data 15 octombrie 2012 12:18:28
Problema Pascal Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include <fstream>

using namespace std;

int max(int a, int b)
{
    if(a < b) return b;
    else return a;
}

int main()
{
    int r, d, q, f, t, w;
    ifstream fin("pascal.in");
    ofstream fout("pascal.out");
    fin>>r; fin>>d;
    q = r%2;
    f = r%3;
    t = r%4;
    w = r%5;
    if(d == 2)
    {
        fout << max((r-1-2*q), 0);
    }
    if(d == 3)
    {
        fout<<max(0, (r-1-2*f));
    }
    if(d == 4)
    {
        fout<<max(0, (r-1-2*t));
    }
    if(d == 5)
    {
        fout<<max(0, (r-1-2*w));
    }
    if(d == 6)
    {
        fout<<max(0, (r-1-2*max(q,f)));
    }
    return 0;
}