10924 - Prime Words

All about problems in Volume 109. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

fuad420
New poster
Posts: 3
Joined: Wed Jul 04, 2007 3:05 pm
Location: East West University

Post by fuad420 » Wed Jul 04, 2007 3:09 pm

:D How comes 1 a prime number?????????!!!!!!!! that is really funny and joking.

bishop
New poster
Posts: 43
Joined: Fri May 04, 2007 12:57 pm

why wa

Post by bishop » Mon Jul 09, 2007 9:48 pm

it show prime num 1
but still Wrong answer
plz help for

Code: Select all

deleted

thanks
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.

User avatar
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am
Contact:

Post by Rocky » Mon Jul 09, 2007 11:48 pm

u need to check ur code again.it need too many modification....
u do p[2]=false but 2 is prime....
again u loop from 3 up to 35....but what happen for 4,8,....it is not prime too.
and ur sum is also incorrect for UPPERCASE.check it.

GOOD LUCK
Rocky

starrynight
New poster
Posts: 7
Joined: Mon Mar 05, 2007 3:24 pm

10924 WA

Post by starrynight » Wed Aug 01, 2007 7:10 am

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



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;
} 
    

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo » Wed Aug 01, 2007 7:51 am

Try this case..

Code: Select all

a
b
c
d
e
A
B
C
D
E
My output is..

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.

laicc86
New poster
Posts: 5
Joined: Sun Oct 07, 2007 6:52 pm

Post by laicc86 » Wed Dec 05, 2007 7:17 am

Code: Select all

removed*  
can anyone help me? i don't know why i got WA for this.
Last edited by laicc86 on Sat Dec 08, 2007 10:00 am, edited 1 time in total.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo » Wed Dec 05, 2007 8:23 am

gets returns NULL instead of EOF at the end of input..


PS. remove your code after AC..

laicc86
New poster
Posts: 5
Joined: Sun Oct 07, 2007 6:52 pm

Post by laicc86 » Wed Dec 05, 2007 12:30 pm

helloneo wrote:gets returns NULL instead of EOF at the end of input..


PS. remove your code after AC..
thx for helping~ but i still get WA after i changed the EOF to NULL :(

turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Post by turcse143 » Wed Dec 19, 2007 5:33 pm

It is very simple problem.
Use the ASCII value & subtract to generate the number check number is prime or not.
For reducing the time u will generate all the prime of the given range before.

ligregni
New poster
Posts: 11
Joined: Thu Nov 29, 2007 12:41 am
Location: Queretaro, M
Contact:

WA I don't know why!

Post by ligregni » Mon Dec 24, 2007 9:44 pm

hi!, this is my code

Code: Select all

/* Prime Words */

REMOVED, got AC
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 end

Code: Select all

if (1)
			printf("\n");
changed by

Code: Select all

if (c!=EOF)
			printf("\n");
and it is the same.

Please HELP!!!

I have SOME ADVICES!
an EMPY string should NOT to print ANYTHING
1 is prime
print a \n after ALL cases
[/quote]
C: multum in parvo

"a lot since quite few"

http://acmicpc-live-archive.uva.es/nuev ... user=12539

aliahmed
New poster
Posts: 24
Joined: Fri Oct 24, 2008 8:37 pm
Location: CUET, Chittagong, Bangladesh
Contact:

Re: 10924 - Prime Words

Post by aliahmed » Wed Oct 29, 2008 12:50 am

AC.
Last edited by aliahmed on Mon Jan 19, 2009 9:40 pm, edited 1 time in total.

sazzadcsedu
Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.
Contact:

Re: 10924 - Prime Words

Post by sazzadcsedu » Sun Dec 28, 2008 12:34 am

whats wrong with this 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

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: 10924 - Prime Words

Post by mf » Sun Dec 28, 2008 3:32 am

sazzadcsedu wrote:whats wrong with this code!!!!!!!!!

i got WA.
Oh really? I think you should have got compile error with the code you've posted.

After you fix it, you might want to check again this part of your code:

Code: Select all

				  memset(prime,0,sizeof(prime));

				    for(i=2;i<=20;i++)

					   {
						   for(j=2;j<=60;j++)

						   {   
							   prime[i*j]=1;

                                                   }
					  } 
E.g. 1018=2*519 is composite, but your code would claim it's not.

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.

sazzadcsedu
Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.
Contact:

Re: 10924 - Prime Words

Post by sazzadcsedu » Sun Dec 28, 2008 8:48 pm

Infact i made a stupid mistake.
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

mintae71
New poster
Posts: 18
Joined: Tue Jan 19, 2010 10:50 am

10924 - Prime Words

Post by mintae71 » Thu Jan 21, 2010 8:28 am

Please help me..... :cry: :cry: :cry:

Here is my code.

Code: Select all

Removed after got AC
please help me....

Please check my code or give me a sample of test data...

Post Reply

Return to “Volume 109 (10900-10999)”