Pagini recente » Cod sursa (job #3211780) | Cod sursa (job #2487853) | Cod sursa (job #2052387) | Cod sursa (job #2962868) | Cod sursa (job #797951)
Cod sursa(job #797951)
#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;
}