Cod sursa(job #2617728)

Utilizator DeepDownMysteryDeep Down DeepDownMystery Data 22 mai 2020 18:16:49
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <iostream>
#include <fstream>


using namespace std;

ifstream f("cmmdc.in");
ofstream g("cmmdc.out");

int main()
{
    int a, b, ok=0, ok1=0;
    f >> a >> b;

    for(int i=2; i<=a/2; i++)
    {
        if(a%i == 0)
        ok = 1;
    }
    for(int i=2; i<=b/2; i++)
    {
        if(b%i == 0)
        ok1 = 1;
    }

    if(ok == 0 && ok1 == 0)
    g << "0";

    else
    {
        while(a != b)
        {
            if(a>b)
            a = a - b;
            else
            b = b - a;
        }
        g << a;
    }

    return 0;
}