ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1118. Нетривиальные числа

i have seen the ac pro of pas,but i use c++ but can't got AC,any master can help me ?
Послано kkgz 21 апр 2004 08:50
#include<iostream.h>
#include<math.h>
#include<limits.h>
main()
{
    long D,U,i,sum,crno,minN,j;
    double min,ratio,nouse;
    int flag=0;
    cin>>D>>U;
    min=1000000;
    minN=D;
    for(long t=1000000;t>=2;t--)
    {
        U=t;
    if(D==1)
        cout<<'0';
    else
    {
        for(i=U;i>=D;i--)
        {
            sum=1;

            for(j=2;j<=sqrt((double)i);j++)
            {
                if(i%j==0)
                {
                    sum+=j+i/j;
                }
            }
            if(i%(j-1)==0)
                sum-=j;

            ratio=double(sum)/(double)i;
            if(ratio<=min)
            {

                min=ratio;
                minN=i;
                if(sum==1)
                {
                    for(long k=U;k>=D;k--)
                    {

                        if(modf(sqrt((double)k),&nouse)==0)
                        {
                            ratio=(1+sqrt((double)k))/(double)k;
                            if(ratio>min)
                                break;
                            else
                            {

                                min=k;
                                minN=k;
                                break;
                            }
                        }
                    }
                    break;
                }

            }
        }
        cout<<minN;
    }
    }
}
Re: i have seen the ac pro of pas,but i use c++ but can't got AC,any master can help me ?
Послано Gheorghe Stefan 22 апр 2004 16:57
if there are prime numbers in the interval you should print it. Else, if there are not primes in the interval, it is quite small and you can brute search the number. If the first bound of the interval is 1 you must print 1 (I got many WAs not knowing this).
Re: i have seen the ac pro of pas,but i use c++ but can't got AC,any master can help me ?
Послано Evil Cheater 28 апр 2004 09:51
I'm doing exactly that but I keep getting WA. Could you give me some sample inputs/outputs?