ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1118. Nontrivial Numbers

help me please
Posted by Nash 8 Jul 2007 00:27



Help me please in my problem 1118 My code:
#include <stdio.h>

#pragma comment(linker, "/STACK:16777216")
int a,b,c,i,k,n,j;
float min = 6555,d;

void main()
{
scanf("%d",&a);
scanf("%d",&b);

for(i=a;i<=b;i++)
    {

    {n=0;
        for(k=1;k<=b/2;k++)
        {

            {if(i%k==0)
                {

                    n=n+k;


                }

            }
            }


            d=(float)n/i;

            if (d<min)
            {
                min=d;
                j=i;
            }



    }
printf("%d",j);
    }



}

I have Time limit exceeded. I need optimal solution of this task. Help me please!
my @ is nash88@mail.ru

Edited by author 08.07.2007 00:28

Edited by author 08.07.2007 00:28