Editorial for Делители


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.
by: maya

Тестовете можете да видите тук.

Примерно решение на C++:

#include<iostream>
using namespace std;
int main()
{
    long long m,m1,n,n1,nod,br=0,i,k;
    cin>>m>>n;
    m1=m;
    n1=n;
    for(i=1; m!=n; i++)
    {
        if(m>n) m=m-n;
        else n=n-m;
    }

    nod=m;
    if(nod==1)
         cout<<-1<<" ";
    for(i=2; i<=nod; i++)
    {
        br=0;
        for(;;)
        {
            if(nod%i==0)
            {
                br++;
                nod=nod/i;
            }
          else break;
        }
      if(br!=0)
      cout<<i<<" ";
    }

    return 0;
}

Comments

There are no comments at the moment.