10042 - Smith Numbers

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

Moderator: Board moderators

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

10042Need I/O Help Pls...................????

Post by Rocky » Mon Mar 14, 2005 12:14 pm

Hi I Try To Solve 10042 But Every Time Get WA.
Can Any Body Give Me Some Input For Test.

Thanks In Advance

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

10042

Post by WR » Mon Mar 14, 2005 5:03 pm

What does your program print for

input:

Code: Select all

7
5
22
31
4937774
4937775
999999999
31601
?

Raj Ariyan
Learning poster
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul

Output

Post by Raj Ariyan » Mon Mar 14, 2005 5:51 pm

Hi,

Here is your output :-
22
27
58
4937775
4937818
1000000165
31639
Good Luck.
Some Love Stories Live Forever ....

Raj Ariyan
Learning poster
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul

Output

Post by Raj Ariyan » Mon Mar 14, 2005 5:51 pm

Cut.
Last edited by Raj Ariyan on Tue Mar 15, 2005 1:07 pm, edited 1 time in total.
Some Love Stories Live Forever ....

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Tue Mar 15, 2005 8:48 am

I know.

That example was supposed to help zprian.

Thanks for having a look.

zprian
New poster
Posts: 13
Joined: Wed Mar 09, 2005 1:16 am

Post by zprian » Tue Mar 15, 2005 8:54 pm

yes, this is my output, and what's wrong??
22,27,58,4937775,4937818,1000000165 and 31639 are smith numbers, or no?
22= 2+2=4-->2+1+1=4
27=2+7=9-->3+3+3=9
...
1000000165=1+1+6+5=13;-->5+200000033=5+2+3+3=13(200000033 is prime)

what's should be the output with a input greater than 1e9??
I prove

if(aux>=1e9){//greater
cout<<999999999<<endl;
return;}
and
if(aux>=1e9){//greater
//cout<<999999999<<endl;
return;}
and calculate the number, but always WA?? :cry:
I don't know anything to do..

thanks WR and Raj Ariyan

zprian
New poster
Posts: 13
Joined: Wed Mar 09, 2005 1:16 am

Post by zprian » Tue Mar 15, 2005 8:59 pm

in this post you have an input and output ;)
http://online-judge.uva.es/board/viewtopic.php?t=7694
i have WA too, but the input is correct.

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Wed Mar 16, 2005 9:28 am

zprian, what's the output of your program for

Code: Select all

180
8
4
8
2
10
3
3
3
5
3
10
3
10
4
3
1
7
6
2
4
29
7
63
49
30
37
23
98
49
63
24
78
44
60
86
83
2
81
20
79
737
261
411
236
115
765
47
368
553
977
449
909
301
332
853
718
480
662
821
34
7274
7645
1459
91
6500
1408
3675
5989
4106
7082
9038
7050
6877
2342
4460
455
7739
8865
5440
8749
91226
49761
24137
33600
61175
26002
68958
19259
17921
39499
67706
87664
88465
48902
82654
67055
97634
87691
8258
85733
42241
211125
493689
655858
50597
62752
823534
958885
697749
787646
829967
970421
656127
797818
631055
15833
822797
586200
625426
132454
6184671
6506550
6324697
2148585
7796713
5097856
1828210
4689521
2718257
4629658
2616492
7607911
3485356
5612526
7019888
537065
2826990
5014099
2609990
3653060
13809658
77500854
13341792
36373302
4144382
78600815
53764165
74770558
10634800
60156887
1321295
14842841
37990918
26230042
83176394
52960681
71876490
86285186
77234001
37502308
742021196
378851202
561253894
352561207
916260549
397393667
958203544
972539791
310314607
148922294
932273285
270193769
521042247
53990017
90931267
516762062
637893954
48590923
222033921
552869522
?

There shouldn't be an input larger than 10^9. My program ignores that and prints the next number anyway. So you shouldn't worry about that, there's probably no incorrect input.

zprian
New poster
Posts: 13
Joined: Wed Mar 09, 2005 1:16 am

Post by zprian » Wed Mar 16, 2005 7:21 pm

hi WR,I prove your input and this is my output :wink:
22
22
22
4
22
4
4
4
22
4
22
4
22
22
4
4
22
22
4
22
58
22
85
58
58
58
27
121
58
85
27
85
58
85
94
85
4
85
22
85
762
265
438
265
121
778
58
378
562
985
454
913
319
346
861
728
483
663
825
58
7287
7674
1507
94
6502
1449
3690
5998
4126
7089
9094
7051
6880
2362
4464
483
7762
8874
5458
8754
91255
49803
24142
33632
61177
26014
69135
19272
17940
39505
67722
87815
88494
48915
82665
67067
97906
87815
8277
85748
42272
211686
493734
655906
50602
62754
823558
958911
697800
787662
830065
970429
656277
797829
631095
15835
822798
586210
625434
132528
6184761
6506560
6324718
2148619
7796722
5097968
1828219
4689621
2718264
4629678
2616537
7607970
3485362
5612566
7019905
537129
2827016
5014255
2609995
3653086
13809678
77500894
13341847
36373335
4144389
78600849
53764195
74770568
10634889
60156913
1321449
14842854
37990944
26230059
83176450
52960692
71876542
86285190
77234062
37502316
742021222
378851206
561253904
352561209
916260574
397393680
958203546
972539834
310314662
148922342
932273295
270193794
521042647
53990043
90931269
516762067
637893994
48590995
222033946
552869590
i think that's ok...
thanks a lot WR

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Thu Mar 17, 2005 8:46 am

Yes, the output's ok.

zprian
New poster
Posts: 13
Joined: Wed Mar 09, 2005 1:16 am

Post by zprian » Sat Mar 19, 2005 2:13 pm

thanks WR :wink:
who can tell me one solution of my problem???

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Mon Mar 21, 2005 10:10 am

Two questions:

1) What exactly does your program do, when the input is greater than 1e9?

2) Do you compile a table of 50000 primes or a table of primes up to 50000?

zprian
New poster
Posts: 13
Joined: Wed Mar 09, 2005 1:16 am

Post by zprian » Tue Mar 22, 2005 1:30 am

hi WR,
1) I prove to write a new line, but I obtained a WA.
I prove to write the first smith number greater than 1e9,but I obtained a WA.
I prove to NO write anything, but I obtained a WA.

and.. I don't know what can I prove...

2)My program find the prime numbers lowest than 50000, becose the sqrt of 1e9 is lowest to 1e5.. and I prove to find the prmie numbers lowest than 1000.000 too.. but.. always I obtained a WA.

I heard that is possible that the error is the type of data that write.
for example... for unsigned long it's ok, but if my program write a unsigned int I obtain WA.I don't know if that is correct, but.. I prove and I obtained WA... :cry:

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Tue Mar 22, 2005 8:50 am

I use long for all variables and it's ok.

Checking each candidate number for primality is a bit slower than using a table but it works.

The only other error I can think of right now is an invalid format specifier, like using %d instead of %ld.

If nothing else helps you'll probably have to post your code.

zprian
New poster
Posts: 13
Joined: Wed Mar 09, 2005 1:16 am

Post by zprian » Wed Mar 23, 2005 12:19 am

OK.In first time I try to check each number, but I obtained a TLE, for that reason I prove the table.
When I'll prove the changes I'll said you the results, ok??
And thanks very much for all, I'm in debt with you :wink:
thanks.

Post Reply

Return to “Volume 100 (10000-10099)”