Cod sursa(job #1250284)
Utilizator | Data | 27 octombrie 2014 23:08:15 | |
---|---|---|---|
Problema | Dreptunghiuri | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
FILE *f, *o;
f = fopen("dreptunghi.in", "r");
o = fopen("dreptunghi.out", "w");
int n, m, moves, k, i;
fscanf_s(f, "%d %d", &m, &n);
if (n > m)
{
k = n;
n = m;
m = k;
}
if (n == m)
moves = n;
else if (m % n == 0)
moves = m;
else
{
moves = n;
k = m - n;
for (i = 1; i <= k; i++)
moves += (n / k);
if (n%k!=0)
moves += k;
}
fprintf(o, "%d", moves);
_getch();
fclose(f);
fclose(o);
return 0;
}