← Back to topics
Topic

divInts

karakondzula
I can't find what's wrong and I can't find any example that give me wrong output. Please help.

What did I do:
- sort input
- for every number check is there divisor before him
- if there is, calculate size and save position

Problem is not in lexicographically order.

http://www.z-trening.com/submit.php?subm_stat=1&submit=7100089515
halil
...
for(i=n;i>0;i--)
{
for(j=i+1;j<=n;j++)
{
if(a[j]%a[i]==0 && size[j]>=size[i])
{
size[i]=size[j]+1;
prev[j]=i;
}
}

if(size[i]>=m)
{
....
karakondzula
I assumed that you are suggesting to go from biggest to smallest instead of other way around and it passed, thanks.
You didn't have to write code, explanation would be enough.
halil
My english ... hmmm. Because the code.