12502 - Three Families

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

Moderator: Board moderators

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 12502 - Three Families

Post by Shahidul.CSE » Sat Sep 13, 2014 7:58 pm

brianfry713 wrote:Try solving it without using floating-point numbers.
But when I try to use int instead of double, then for many input my program failed to give correct output.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 12502 - Three Families

Post by lighted » Mon Sep 15, 2014 3:50 pm

Your code is ok. Just change line to

Code: Select all

ans = floor(a * amount / h + 1e-8);
or

Code: Select all

ans = a * amount / h;
According to problem description input 1 1 1 is invalid.
It is guaranteed that both families should get non-negative integer dollars.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 12502 - Three Families

Post by Shahidul.CSE » Wed Sep 17, 2014 6:04 pm

Thanks, lighted ! Got accepted :D
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com

mhsn06
New poster
Posts: 16
Joined: Tue Apr 01, 2014 7:36 pm

Re: 12502 - Three Families

Post by mhsn06 » Fri Sep 19, 2014 11:07 am

what will be the output for this?

Code: Select all

1
6 2 500

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 12502 - Three Families

Post by Shahidul.CSE » Fri Sep 19, 2014 11:17 am

mhsn06 wrote:what will be the output for this?

Code: Select all

1
6 2 500
For this case, my Accepted code gives output:

Code: Select all

625
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com

mhsn06
New poster
Posts: 16
Joined: Tue Apr 01, 2014 7:36 pm

Re: 12502 - Three Families

Post by mhsn06 » Fri Sep 19, 2014 11:39 am

Yes, I got AC with that. But how can A get bigger amount than input. Didn't I get the problem correctly?
If family A and B spent x and y hours respectively, and family C paid $z, how much should family A get?

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 12502 - Three Families

Post by lighted » Fri Sep 19, 2014 11:56 am

mhsn06 wrote:what will be the output for this?

Code: Select all

1
6 2 500
My Acc Output

Code: Select all

500
But i think it's invalid input because according to problem description it is guaranteed that both families should get non-negative integer dollars. So sum of x and y should be divisible by 3.

Input

Code: Select all

1
7 2 500
Acc Output

Code: Select all

500
Maybe judge's input is weak.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

mhsn06
New poster
Posts: 16
Joined: Tue Apr 01, 2014 7:36 pm

Re: 12502 - Three Families

Post by mhsn06 » Fri Sep 19, 2014 5:53 pm

Thanks lighted for your explanation.

anacharsis
Learning poster
Posts: 69
Joined: Mon Feb 09, 2015 1:56 am

Re: 12502 - Three Families

Post by anacharsis » Thu Sep 03, 2015 3:24 pm

In:

Code: Select all

100
7 10 898
4 5 484
6 6 507
9 3 871
9 3 705
3 4 30
7 2 201
6 1 109
3 3 898
9 7 398
5 4 287
1 7 544
3 7 245
5 10 951
3 8 521
2 7 109
4 6 530
5 6 587
7 10 972
9 4 347
6 6 108
7 1 546
10 4 720
5 5 784
8 3 397
3 4 768
2 9 297
2 3 987
3 2 349
4 2 461
8 9 171
2 5 273
3 6 119
10 10 919
9 5 160
8 9 825
10 5 731
9 4 291
3 4 752
10 4 618
2 6 666
2 6 136
5 7 38
4 10 292
7 9 554
7 10 373
8 8 530
1 7 555
4 6 862
2 4 193
9 2 703
6 7 175
8 6 584
2 9 505
1 9 354
8 6 857
7 7 78
1 2 232
6 8 285
5 4 680
5 4 126
1 5 95
5 6 590
5 3 425
1 7 120
9 5 844
2 7 104
1 7 316
8 7 671
1 10 48
4 5 429
1 4 74
9 6 644
5 1 337
7 8 525
1 9 332
6 4 287
8 9 798
1 3 631
9 2 879
8 10 867
9 4 345
1 5 746
3 10 227
3 3 597
3 7 783
10 9 896
6 3 906
5 9 688
1 7 612
8 4 639
10 5 534
8 7 848
5 10 235
5 4 348
1 6 627
10 8 104
3 5 106
8 2 221
3 7 851
AC Out:

Code: Select all

211
161
253
1088
881
8
268
171
449
273
191
0
0
0
0
0
106
213
228
373
54
887
822
392
469
219
0
197
279
461
70
0
0
459
148
339
731
313
214
706
0
0
9
0
173
87
265
0
172
0
1022
67
417
0
0
612
39
0
81
453
84
0
214
371
0
783
0
0
402
0
143
0
515
505
210
0
229
328
0
1278
289
371
0
0
298
0
518
906
49
0
639
534
508
0
232
0
69
13
309
0

Post Reply

Return to “Volume 125 (12500-12599)”