## 12555 - Baby Me

Moderator: Board moderators

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

### Re: 12555 - Baby Me

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
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

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

### Re: 12555 - Baby Me

Thanks lighted ! I now understood it
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
Email me: shahidul.cse.brur@gmail.com

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

### Re: 12555 - Baby Me

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

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