![:D](./images/smilies/icon_biggrin.gif)
10924 - Prime Words
Moderator: Board moderators
why wa
it show prime num 1
but still Wrong answer
plz help for
thanks
but in upper post
1,3,5...... odd number denoted by prime number
so i thought 2 is not prime
but still Wrong answer
plz help for
Code: Select all
deleted
but in upper post
1,3,5...... odd number denoted by prime number
so i thought 2 is not prime
Last edited by bishop on Tue Jul 10, 2007 9:55 am, edited 1 time in total.
-
- New poster
- Posts: 7
- Joined: Mon Mar 05, 2007 3:24 pm
10924 WA
excuse me ,can anyone tell me why I got a WA?
because I can't find where I do wrong .
thanks in advance
and sorry for my poor English..
because I can't find where I do wrong .
thanks in advance
![:)](./images/smilies/icon_smile.gif)
and sorry for my poor English..
Code: Select all
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
char word[21];
double sum=0;
int i,y,factor;
while(gets(word) != NULL)
{
factor=0;
for(i=0;i<20;i++)
{
if(word[i]>='a' && word[i]<='z')
sum = sum +(word[i]-96);
else if(word[i]>='A' && word[i]<='Z')
sum = sum +(word[i]-38);
}
for (y = 2; y <= sqrt(sum); y++)
{
if ( fmod(sum,y)==0 )
factor++;
}
if (factor == 0)
printf("It is a prime word.\n");
else
printf("It is not a prime word.\n");
}
return 0;
}
Try this case..
My output is..
Code: Select all
a
b
c
d
e
A
B
C
D
E
Code: Select all
It is a prime word.
It is a prime word.
It is a prime word.
It is not a prime word.
It is a prime word.
It is not a prime word.
It is not a prime word.
It is a prime word.
It is not a prime word.
It is a prime word.
Code: Select all
removed*
Last edited by laicc86 on Sat Dec 08, 2007 10:00 am, edited 1 time in total.
WA I don't know why!
hi!, this is my code
I tried all the single letters, the example cases, the test cases here, and I still getting WA with almost no time (sometimes 0.010 or other times 0.000), I also tried not to print the '\n' at the endchanged byand it is the same.
Please HELP!!!
I have SOME ADVICES!
Code: Select all
/* Prime Words */
REMOVED, got AC
Code: Select all
if (1)
printf("\n");
Code: Select all
if (c!=EOF)
printf("\n");
Please HELP!!!
I have SOME ADVICES!
an EMPY string should NOT to print ANYTHING
1 is prime
[/quote]print a \n after ALL cases
-
- New poster
- Posts: 24
- Joined: Fri Oct 24, 2008 8:37 pm
- Location: CUET, Chittagong, Bangladesh
- Contact:
Re: 10924 - Prime Words
AC.
Last edited by aliahmed on Mon Jan 19, 2009 9:40 pm, edited 1 time in total.
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
Re: 10924 - Prime Words
whats wrong with this code!!!!!!!!!
i got WA.
try my best.but cant find the problem.
plz plz someone help.
here is my code
i got WA.
try my best.but cant find the problem.
plz plz someone help.
here is my code
Code: Select all
removed after being AC.
Last edited by sazzadcsedu on Sun Dec 28, 2008 8:51 pm, edited 1 time in total.
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
Re: 10924 - Prime Words
Oh really? I think you should have got compile error with the code you've posted.sazzadcsedu wrote:whats wrong with this code!!!!!!!!!
i got WA.
After you fix it, you might want to check again this part of your code:
E.g. 1018=2*519 is composite, but your code would claim it's not.Code: Select all
memset(prime,0,sizeof(prime)); for(i=2;i<=20;i++) { for(j=2;j<=60;j++) { prime[i*j]=1; } }
Horrible indenting, btw. If it's not caused by a forum bug (tab=3 spaces), I think you really need to learn some good indenting style.
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
Re: 10924 - Prime Words
Infact i made a stupid mistake.
but now got AC.
thanx a lot mf.
need ur help later(comming!!!).
but now got AC.
thanx a lot mf.
need ur help later(comming!!!).
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
10924 - Prime Words
Please help me.....
Here is my code.
please help me....
Please check my code or give me a sample of test data...
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
Here is my code.
Code: Select all
Removed after got AC
Please check my code or give me a sample of test data...