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

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

Why CE!?Help me!I have comiled it in my computer!!!
Послано bbs.hasea.com 13 сен 2007 17:10
#include <iostream>
#include <math.h>

using namespace std;

long long a,b;
long long i,j;
long long sum,maxi;
double s;
double maxn;

int main ()
{
    cin>>a>>b;
    maxn=100000;
    for (i=a;i<=b;i++)
        {
        sum=1;
        for (j=2;j<sqrt(i);j++)
            if (i%j==0) sum=sum+j+i/j;
        if (((long long)(sqrt(i)))*((long long)(sqrt(i)))==i) sum=sum+(long long)(sqrt(i));
        s=(double)sum/i;
        if (s<maxn) {
                    maxn=s;
                    maxi=i;
                    }
        }
    cout<<maxi<<endl;
    return (0);
}

Edited by author 13.09.2007 17:13
Re: Why CE!?Help me!I have comiled it in my computer!!!
Послано Alias (Alexander Prudaev) 13 сен 2007 20:04
try to overload function "sqrt" for "long long"

long long sqrt(long long x)
{
return (long long)sqrt((double) x);
}

by the way you must to use "__int64" instead of "long long"

you can use option "Reply" when submit your solution
To this E-Mail address your@email.adress
and you have got such a message:


You tried to solve problem 1118 Nontrivial numbers.
Your solution was compiled with the following errors:

641078b2-a88c-43db-be02-6b6e5e5dd8fc
641078b2-a88c-43db-be02-6b6e5e5dd8fc(21): error: more than one instance of overloaded function "sqrt" matches the
argument list:
            function "sqrt(double)"
            function "sqrt(float)"
            function "sqrt(long double)"
            argument types are: (__int64)
  for (j=2;j<sqrt(i);j++)
             ^

641078b2-a88c-43db-be02-6b6e5e5dd8fc(23): error: more than one instance of overloaded function "sqrt" matches the
argument list:
            function "sqrt(double)"
            function "sqrt(float)"
            function "sqrt(long double)"
            argument types are: (__int64)
  if (((long long)(sqrt(i)))*((long long)(sqrt(i)))==i) sum=sum+(long long)(sqrt(i));
                   ^

641078b2-a88c-43db-be02-6b6e5e5dd8fc(23): error: more than one instance of overloaded function "sqrt" matches the
argument list:
            function "sqrt(double)"
            function "sqrt(float)"
            function "sqrt(long double)"
            argument types are: (__int64)
  if (((long long)(sqrt(i)))*((long long)(sqrt(i)))==i) sum=sum+(long long)(sqrt(i));
                                          ^

641078b2-a88c-43db-be02-6b6e5e5dd8fc(23): error: more than one instance of overloaded function "sqrt" matches the
argument list:
            function "sqrt(double)"
            function "sqrt(float)"
            function "sqrt(long double)"
            argument types are: (__int64)
  if (((long long)(sqrt(i)))*((long long)(sqrt(i)))==i) sum=sum+(long long)(sqrt(i));
                                                                            ^

641078b2-a88c-43db-be02-6b6e5e5dd8fc(32): warning #1: last line of file ends without a newline
  }
   ^

compilation aborted for 641078b2-a88c-43db-be02-6b6e5e5dd8fc (code 2)
Re: Why CE!?Help me!I have comiled it in my computer!!!
Послано bbs.hasea.com 14 сен 2007 16:50
I see,and I've AC it