## 10791 - Minimum Sum LCM

Moderator: Board moderators

htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

### 10791 - Minimum Sum LCM

in:
2342
2343
34
1
234
678
67223
76627567
334
787890
787611
0

out:
Case 1: 1173
Case 2: 104
Case 3: 19
Case 4: 2
Case 5: 31
Case 6: 119
Case 7: 5184
Case 8: 22408
Case 9: 169
Case 10: 131321
Case 11: 23900

Could someone give some critical case?

totster
New poster
Posts: 4
Joined: Sun Dec 12, 2004 12:28 pm
htl wrote: in:
2342
2343
34
1
234
678
67223
76627567
334
787890
787611
0

out:
Case 1: 1173
Case 2: 104
Case 3: 19
Case 4: 2
Case 5: 31
Case 6: 119
Case 7: 5184
Case 8: 22408
Case 9: 169
Case 10: 131321
Case 11: 23900
I get:

Case 1: 1173
Case 2: 85
Case 3: 19
Case 4: 2
Case 5: 24
Case 6: 118
Case 7: 5184
Case 8: 4829
Case 9: 169
Case 10: 26273
Case 11: 866

htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan
I think I could understand your algorithm. But what's wrong with my program? Any critical case could cause error?

krijger
New poster
Posts: 39
Joined: Wed Jul 21, 2004 12:35 am
I think you misunderstand the problem. The problem description reads:
a set of AT LEAST two positive integers

htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan
I have modified my code that I get the same answer as above. But I still got WA. I don't know what I haven't paid attention to.

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
You have to use unsigned int for the result, since input can be: 2^31 - 1, so output is 2^31.
Last edited by Adrian Kuegel on Sun Dec 12, 2004 6:22 pm, edited 1 time in total.

unknown_error
New poster
Posts: 5
Joined: Fri Dec 10, 2004 9:42 am
for input 2^31-1 the output is 2^31. so, it's better to use unsigned int or long long .. for this silly mistake i needed 5 submission during the contest to get AC

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
Sure, output is 2^31 in that case. Sorry for my typo.

harry
New poster
Posts: 20
Joined: Mon Aug 30, 2004 10:20 pm
Location: HK
hi totster.
should the answer of 234 be 21.
you have write for 234 , 24
atleat i can say that 234=2*3*3*13,then sum =21.

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
But lcm of 2,3,3,13 is 78, so your result is wrong.

harry
New poster
Posts: 20
Joined: Mon Aug 30, 2004 10:20 pm
Location: HK
what abt 4
4 = 4,since 2*2=4 but lcm of 2,2=2;//corrcted
or 4 = 5, 4*1=4,4+1=5
Last edited by harry on Sun Dec 12, 2004 8:15 pm, edited 1 time in total.

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
Sure, for 4 the output should be 5.
Last edited by Adrian Kuegel on Sun Dec 12, 2004 8:18 pm, edited 1 time in total.

harry
New poster
Posts: 20
Joined: Mon Aug 30, 2004 10:20 pm
Location: HK
now i am a bit confused.how can i get solution for such input.