10789 - Prime Frequency

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

Moderator: Board moderators

Ndiyaa ndako
New poster
Posts: 21
Joined: Sat Sep 25, 2004 3:35 am
Location: Oaxaca de Ju
Contact:

10789 - Wrong Answer

Post by Ndiyaa ndako »

This problem is driving me mad! Those who had got it accepted, how did you read the input?

In a part of my code, I do the following cast

[cpp]
u = (int)cadena[j];

cout << (char)j;
[/cpp]

Is this valid? Would it produce the right output?
Antonio Ocampo
Experienced poster
Posts: 131
Joined: Sat Jul 17, 2004 4:09 am
Location: Lima, Per

Post by Antonio Ocampo »

Hi buddy

In my AC program the I/O is like this:

[cpp]

scanf("%s",cad);
.....
if( es_primo(frecuencia[j]) )
{
flag=true; //flag indica si ya se escribio un caracter
putchar(j);
}

[/cpp]

Hope this helps :D
CodeMaker
Experienced poster
Posts: 183
Joined: Thu Nov 11, 2004 12:35 pm
Location: AIUB, Bangladesh

Post by CodeMaker »

Hi all, i dont understand why I am geting WA.........what's wrong? :cry:
[c] Accepted Now[/c]
Last edited by CodeMaker on Mon Dec 13, 2004 4:58 am, edited 1 time in total.
Jalal : AIUB SPARKS
UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post by UFP2161 »

What are the ASCII values of 0-9, A-Z, and a-z? That's your problem.
CodeMaker
Experienced poster
Posts: 183
Joined: Thu Nov 11, 2004 12:35 pm
Location: AIUB, Bangladesh

Post by CodeMaker »

:D Hi, Thanks for the help....I got Acc after I changed into a single 500 size array, I think 300 will do, but for safety I used 500 size and it worked.
Jalal : AIUB SPARKS
schindlersp
New poster
Posts: 28
Joined: Tue Aug 03, 2004 8:11 pm
Contact:

10789 - Prime Frequency

Post by schindlersp »

i don't understand ... where to be wrong?

[cpp]


//---------------------------------------------------------------------------



//---------------------------------------------------------------------------

[/cpp]


thanks ... for help
Last edited by schindlersp on Thu Dec 16, 2004 12:22 am, edited 1 time in total.
Ndiyaa ndako
New poster
Posts: 21
Joined: Sat Sep 25, 2004 3:35 am
Location: Oaxaca de Ju
Contact:

Thank you!

Post by Ndiyaa ndako »

Yes, the problem was with the output. Why

[cpp] putchar(j); [/cpp]

works while

[cpp] cout << (char) j; [/cpp]

does not? I really would like to know.
Antonio Ocampo
Experienced poster
Posts: 131
Joined: Sat Jul 17, 2004 4:09 am
Location: Lima, Per

Post by Antonio Ocampo »

Hi

Try this input

[cpp]
10
oieurfndskjbnz000000157986216nvknMANC
idufjdklmvlkue342494832674921487
76583hjfkshgkiKJDNHFKJSkjsdnksi
iutioerniIHGFSDHuyeuiu735982347kkj
nnvnvnnv
a
0
A
0001AA
BBNAaaa9

[/cpp]


Output

[cpp]
Case 1: 16k
Case 2: 234789dklu
Case 3: JKhijs
Case 4: 37Hek
Case 5: nv
Case 6: empty
Case 7: empty
Case 8: empty
Case 9: 0A
Case 10: Ba
[/cpp]


If you want, send me your input file and I will send you my output for it. :wink:
schindlersp
New poster
Posts: 28
Joined: Tue Aug 03, 2004 8:11 pm
Contact:

Post by schindlersp »

thanks Antonio OCampo but i don't get find my err

look my input

16
oieurfndskjbnz000000157986216nvknMANC
idufjdklmvlkue342494832674921487
76583hjfkshgkiKJDNHFKJSkjsdnksi
iutioerniIHGFSDHuyeuiu735982347kkj
nnvnvnnv
a
0
A
0001AA
BBNAaaa9
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaasdiufhushfusdhfsiudfhsdghfygfsugfudsfjknhddifuygufgdufgsdfugsdufgjkbfidug
0a0a0a0a0a0a0a0a0a0a0a0a0a0a0000000000000000000000000000000000000000
aaAAaA000010
AAAZZZzzzzzzzBbBb
123456duahshidhaysdguasgdasuydguasgduasgduasgfuvdgucvdaugcvaducvdgcvsdycvysdgvcysdgvcysdvcgyvdcgyvdycvsygdcvsygdvcygdvsygvcygsdvcygsvdcygvsdygcvsyvc123456
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddaaaffffffffffffeeeeeeeeeeeeeee


Case 1: 16k
Case 2: 234789dklu
Case 3: JKhijs
Case 4: 37Hek
Case 5: nv
Case 6: empty
Case 7: empty
Case 8: empty
Case 9: 0A
Case 10: Ba
Case 11: Aadgjksy
Case 12: empty
Case 13: 0Aa
Case 14: ABZbz
Case 15: 123456acdh
Case 16: a
has critical input?? :o

thanks ...[/code]
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

My output:
Case 1: 16k
Case 2: 234789dklu
Case 3: JKhijs
Case 4: 37Hek
Case 5: nv
Case 6: empty
Case 7: empty
Case 8: empty
Case 9: 0A
Case 10: Ba
Case 11: Aadjky
Case 12: empty
Case 13: 0Aa
Case 14: ABZbz
Case 15: 123456cdh
Case 16: a
There are differences in case 11 and 15.
schindlersp
New poster
Posts: 28
Joined: Tue Aug 03, 2004 8:11 pm
Contact:

10789 ac

Post by schindlersp »

Thanks i get AC

no problem with my code :oops:

isPrime() don't work ..

while ( retorno && (d*d < n) ) // in my isPrime 9 is prime
Antonio Ocampo
Experienced poster
Posts: 131
Joined: Sat Jul 17, 2004 4:09 am
Location: Lima, Per

Post by Antonio Ocampo »


Yes, the problem was with the output. Why

C++:
putchar(j);


works while

C++:
cout << (char) j;
Well, in case of my code "j" is a character therefore I could write it with putchar(j) or with "cout<<j"

But I don
I LIKE GN
Learning poster
Posts: 57
Joined: Fri Oct 10, 2003 11:01 pm
Location: in front of PC
Contact:

Post by I LIKE GN »

Extremely Srry for posting wrong code...
Last edited by I LIKE GN on Thu Aug 18, 2005 3:13 pm, edited 1 time in total.
There are two tragedies in life one is to lose your hearts' desire and another is to gain it --- GBS.
wook
Learning poster
Posts: 76
Joined: Fri Oct 01, 2004 11:34 am
Location: Korea, Republic Of

Post by wook »

memset(table+46,0,sizeof(table) );

i think you should fix it like

memset(table,0,sizeof(table) );


because fist code means
set 0, where table[46..46+124]

and it can make memory violation.
Sorry For My Poor English.. :)
I LIKE GN
Learning poster
Posts: 57
Joined: Fri Oct 10, 2003 11:01 pm
Location: in front of PC
Contact:

Please Help

Post by I LIKE GN »

hello wook
really ur advice worked (but strange my vcc 6.0 worked with the previous code)
so thank UUUUU!!!!!!!
Last edited by I LIKE GN on Thu Aug 18, 2005 3:11 pm, edited 1 time in total.
There are two tragedies in life one is to lose your hearts' desire and another is to gain it --- GBS.
Post Reply

Return to “Volume 107 (10700-10799)”