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 1086. Cryptography

WHY COMPILE ERROR????HELP PLZ!!!!
Posted by michel mizrahi 18 Mar 2005 08:47
I can't understand why I get compile error!
I don't see nothing strange in my code and it works perfectly in my computer, so I don't know what to change
here is my code:

#include <stdio.h>
#include <math.h>

int p[15003],ind=5;

is_prime(int n){
int i=3,l=sqrt(n)+1;
while(i<l){
if(n%i==0)
return 0;
i+=2;
}
return 1;
}

init(){
int i;
for(i=11;ind<15002;i+=2){
if(is_prime(i)){
p[ind]=i;
ind++;
}
}
}

int main()
{
p[1]=2;p[2]=3;p[3]=5;p[4]=7;
int n,i,k;
init();
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&k);
printf("%d\n",p[k]);
}
return 0;
}

is someone can help me I would appreciate....
thanks!
bye
Re: WHY COMPILE ERROR????HELP PLZ!!!!
Posted by Gheorghe Stefan 18 Mar 2005 12:59
Put SQRTL instead of SQRT and you'll get AC...
Re: WHY COMPILE ERROR????HELP PLZ!!!!
Posted by michel mizrahi 19 Mar 2005 06:22
thanks for your reply
but I try it by changing "sqrt" for "sqrtl" and it doesn't work
maybe it is something else
thanks anyway!
byee
Re: WHY COMPILE ERROR????HELP PLZ!!!!
Posted by Cybernetics Team 19 Mar 2005 19:44
I submitted your source with C++ and sqrtl and got AC...
Re: WHY COMPILE ERROR????HELP PLZ!!!!
Posted by michel mizrahi 21 Mar 2005 06:34
yes you are right
I submit it but in C so I get compilation error
thanks :D !!!!!
Re: WHY COMPILE ERROR????HELP PLZ!!!!
Posted by Akob 24 Mar 2007 13:46
(int)sqrt((double)n)-it is a true
Re: WHY COMPILE ERROR????HELP PLZ!!!!
Posted by Alias (Alexander Prudaev) 25 Mar 2007 11:32
while (i*i<=n) - it's true
or
i = 0;
while (p[i]*p[i]<=n)...