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()
{
    int n,i,k,a[1006],br=0,d,max=0,j,v,b[1006];
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        b[i]=0;
        br=0;
        for(d=2;d<=k;d++)
        if(a[i]%d==0 && k%d==0){br++;b[i]=br;}
        if(max<br)max=br;
        else br=0;
    }
    if(max!=0)
    {   cout<<max<<endl;
        v=0;
    for(i=1;i<=n;i++)
    {

        if(b[i]==max)
        if(v==0){cout<<i; v=1;}
        else cout<<" "<<i;
    }
    }
    else cout<<"No winners"<<endl;

    return 0;
}

Comments

There are no comments at the moment.