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

xplosive
New poster
Posts: 4
Joined: Sat Aug 03, 2013 2:49 pm

12502 - Three Families

Post by xplosive » Tue Sep 03, 2013 7:09 pm

Why i am getting runtime error...? I tried for four time but same result rte...

Code: Select all

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{

    //freopen("uvainput.txt", "r", stdin);
    //freopen("uvaoutput.txt", "w", stdout);

    int t,tt;
    scanf("%d",&tt);

    int x,y,z,ave,over,r;

    for(t=0; t<tt; t++)
    {
        scanf("%d%d%d",&x,&y,&z);

        ave=(x+y)/3;
        over = x-ave;
        r= z*over/ave;

        printf("%d\n",r);


    }


    return 0;
}


brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12502 - Three Families

Post by brianfry713 » Tue Sep 03, 2013 10:01 pm

Try input:

Code: Select all

1
1 1 1
Check input and AC output for thousands of problems on uDebug!

User avatar
mahade hasan
Learning poster
Posts: 87
Joined: Thu Dec 15, 2011 3:08 pm
Location: University of Rajshahi,Bangladesh

Re: 12502 - Three Families

Post by mahade hasan » Thu Oct 31, 2013 6:24 am

brianfry713 wrote:Try input:

Code: Select all

1
1 1 1
out put will be floating
what will be the answer
we r surrounded by happiness
need eyes to feel it!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12502 - Three Families

Post by brianfry713 » Thu Oct 31, 2013 10:46 pm

0
Check input and AC output for thousands of problems on uDebug!

Minarmahmud
New poster
Posts: 4
Joined: Fri Mar 15, 2013 3:09 pm
Location: AIUB, Dhaka, Bangladesh

Re: 12502 - Three Families

Post by Minarmahmud » Sat Dec 07, 2013 10:53 am

brianfry713 wrote:0
Sir, I think the AC output is 1.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12502 - Three Families

Post by brianfry713 » Wed Dec 11, 2013 12:14 am

Either 1 or 0 would make sense. There won't be a case like that in the judge's input.
Check input and AC output for thousands of problems on uDebug!

me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

12502 - Three Families

Post by me33 » Fri Feb 21, 2014 7:28 pm

got WA.
can't find error.

plz help.

removed after AC :lol: :P

cse dipto
New poster
Posts: 22
Joined: Tue Oct 29, 2013 6:46 pm

Re: 12502 - Three Families get WA ! plz help

Post by cse dipto » Fri Mar 21, 2014 8:53 pm

Code: Select all

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <cctype>
#include <stack>
#include <queue>
#include <map>
#include <vector>


using namespace std;

int main()
{
    double i,j,k,t_case,f1,f2,money,dif,tmp;
    int f1_money ;
    cin >> t_case ;
    for(i = 1 ; i <= t_case ; i++)
    {
        dif = 0 ;
        cin >> f1 >> f2 >> money ;
        if(f1 > f2)
            dif = f1 - f2 ;

        tmp = (money / (f1 + f2));
        f1_money = (tmp * (f1 + dif)) ;
        cout << f1_money << endl ;
    }
    return 0;
}

sadee
New poster
Posts: 3
Joined: Sat Mar 08, 2014 9:19 am

Re: 12502 - Three Families

Post by sadee » Sat Mar 22, 2014 1:27 am

Does't Match simple I/O

Code: Select all

Input:
3
6 7 50
3 9 120
11 11 987
your code says:
23
30
246
Last edited by sadee on Sat Mar 22, 2014 1:32 am, edited 1 time in total.

sadee
New poster
Posts: 3
Joined: Sat Mar 08, 2014 9:19 am

Re: 12502 - Three Families

Post by sadee » Sat Mar 22, 2014 1:31 am

time_limit(CUET_Triangle)'s acc code says:

Code: Select all

19
0
493

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 12502 - Three Families

Post by uDebug » Sat Jul 05, 2014 2:31 pm

Beware this is one of those annoyingly clever problems on UVa. The problem statement is confusing (on purpose) - and then if you use floating point numbers you'll likely end up getting a WA.

In regards to the problem statement: What's not made very clear is that the families do not get paid for their own share of the work. Family C is paying Family A and B only for work that Family C did not do.

On the floating point front, think a little outside the box. Maybe a change in time units, perhaps.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

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

Re: 12502 - Three Families

Post by lighted » Sat Sep 06, 2014 4:52 pm

v1n1t wrote:Beware this is one of those annoyingly clever problems on UVa. The problem statement is confusing (on purpose) - and then if you use floating point numbers you'll likely end up getting a WA.

In regards to the problem statement: What's not made very clear is that the families do not get paid for their own share of the work. Family C is paying Family A and B only for work that Family C did not do.

On the floating point front, think a little outside the box. Maybe a change in time units, perhaps.
I got accepted using only double for variables. :)
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 » Sat Sep 13, 2014 4:03 pm

I am getting WA with my code. Whats wrong?

Code: Select all

Accepted !
Last edited by Shahidul.CSE on Wed Sep 17, 2014 6:53 pm, edited 1 time in total.
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

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12502 - Three Families

Post by brianfry713 » Sat Sep 13, 2014 6:39 pm

Try solving it without using floating-point numbers.
Check input and AC output for thousands of problems on uDebug!

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:53 pm

I can't figure out the trick to solve using int . :(
Last edited by Shahidul.CSE on Sat Sep 13, 2014 8:02 pm, edited 1 time in total.
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

Post Reply

Return to “Volume 125 (12500-12599)”