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 1079. Maximum

Compilation error, but i've compiled it using 3 different compilers at home...
Posted by Kirill Vivid 3 Oct 2001 00:31
----------------------------------------------

#include <iostream.h>
#include <math.h>

#define MAX_N 1000
#define MAX_P 15000

int ns[MAX_N];
int N, K;
int M;

int prost[MAX_P];
int count=0;


int main()
{
    M=0;
    cin>>N;

    int i;
    for(i=0; i<N; i++)
    {
        cin>>ns[i];
        if (ns[i]>M)
            M=ns[i];
    }

    prost[0]=2;
    prost[1]=3;
    prost[2]=5;

    count=3;

    int p=7;
    while (count<M)
    {
        int j;
        int qp = (int)sqrt(p)+1;
        for (j=0; (j<count)&&(p%prost[j])&&
(qp>=prost[j]); j++);
        if (p%prost[j])
            prost[count++]=p;

        p+=2;
    }

    for (i=0; i<N; i++)
        cout<<prost[ns[i]-1]<<endl;

    return 0;
}
Re: Compilation error, but i've compiled it using 3 different compilers at home...
Posted by Marat Bakirov 6 Oct 2001 04:20
You tried to solve problem 1069. Your solution on C++ was
compiled with the following errors:

69333
temp\69333(39) : error C2668: 'sqrt' : ambiguous call to
overloaded function


Wonder how I got it ? Just check "I want to recieve result
by email" And you'll get it.

I suggest using something like sqrt((double)p)
It is a common errror