12555 - Baby Me

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

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

Re: 12555 - Baby Me

Post by Shahidul.CSE » Sat Sep 27, 2014 7:14 am

1) In this problem, do ? and ? hold space of three characters each? Because, my compiler (CodeBlocks) shows the length of first simple input
(i.e. 35 ?2 ?) is 11, length of 2nd simple input also 11, and the length of the last simple input is 5.

2) Shouldn't the output contain any trailing zero after decimal point ? such that sample output 1 is 2.6 , if the output be 2.600, will the program get WA?

3) If the output is an integer, shouldn't it contain decimal point ? such that sample output 1 is 3 , if the output be 3.000, will the program get WA?

5) If ans for abpve 2) and 3) is yes, how to control it ?

6) Please give some sample input and output for this problem.

My bellow program getting WA-

Code: Select all

#include<stdio.h>
#include<string.h>
int main()
{
    char dis[500];
    int len,c,t;
    double w;
    scanf("%d",&t);
    getchar();
    for(c=1;c<=t;c++)
    {
        gets(dis);
        len=strlen(dis);
        if(len==5)
            w=(dis[0]-'0')*0.5;
        else
            w=(dis[0]-'0')*0.5 + (dis[6]-'0')*0.05;
        printf("Case %d: %lf\n",c,w);
    }
    return 0;
}
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: 12555 - Baby Me

Post by lighted » Mon Sep 29, 2014 1:53 pm

1) I don't know. I made a loop for all string length and checked for integer values '0'..'9'.

2) Problem description says: "For each test case, print the ACCURATE weight in kg (without trailing zeros)." Yes you will get WA.

3) Third case in sample output shows that if result is integer, than it shouldn't have decimal point. You will get WA for 3.000.

4) You haven't got 4th question. :)

5) Answer for 2) and 3) is YES. scanf and printf have lots of features to do anyway you want. Use %g specifier instead of %lf. printf("Case %d: %g\n", t, result).
If you want to do it manually, try this

Code: Select all

result = a * 50 + b * 5;
 
printf ("%d", result / 100);
 
result %= 100;
 
if ( result ) {
    if (result % 10 == 0) printf (".%d", result / 10);
    else                  printf (".%d", result);
}
6) Input

Code: Select all

4
1?1?
10?9?
5?5?
6?6?
Acc Output

Code: Select all

Case 1: 0.55
Case 2: 5.45
Case 3: 2.75
Case 4: 3.3
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: 12555 - Baby Me

Post by Shahidul.CSE » Mon Sep 29, 2014 4:36 pm

Thanks lighted ! I now understood it :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

vcrazy2
New poster
Posts: 4
Joined: Fri Oct 24, 2014 9:54 pm

Re: 12555 - Baby Me

Post by vcrazy2 » Thu Jan 15, 2015 1:34 pm

I don't know what the bug is, so far I can guess it's showing me right answer.
Please let me know what the problem is. Some critical testcases would be great.

Code: Select all


Removed after AC... Thanks

Last edited by vcrazy2 on Tue Feb 03, 2015 7:52 pm, edited 1 time in total.

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

Re: 12555 - Baby Me

Post by brianfry713 » Fri Jan 16, 2015 12:36 am

It looks like you figured it out.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 125 (12500-12599)”