Page **1** of **1**

### 365 - Welfare Reform

Posted: **Wed May 10, 2006 10:10 pm**

by **Darko**

This one seems easy, but I can't get it right.

I checked for blank lines, there were none.

I dealt with 0's (income, children). I used integers-only and/or doubles and I even used 64-bit integers (who knows, maybe one of those names is Gates).

It looks straight-forward, but I am missing some weird case... any hints?

Posted: **Thu May 11, 2006 8:03 pm**

by **mamun**

This really looks simple but very less number of acceptance and so is its rate. I was trying it just now and already got 4 WA.

Where is the trick? Does name of family contain whitespace? I tried that also.

Children in the same family will not share birthdays.

Doesn't that intend to mean there will be no children with same age? If there is, then what to do if more than one child have the minimum age?

What's the age of following children?

9 1 95

9 2 95

8 30 95

8 31 95

Posted: **Thu May 11, 2006 10:00 pm**

by **Darko**

Thanks mamun for the hint

My WA gave 4 zeros to those, and when I changed it so the first one was 1, it got accepted

I considered names to contain (and start/end with) spaces, but I am not sure if there are such cases.

Make sure you handle k=0 case and that you didn't mix < and <=.

Btw, that "no children will share..." means that there must be the youngest child.

Posted: **Thu May 11, 2006 10:51 pm**

by **mamun**

Nice to see my hint helped you to get AC.

Darko wrote:My WA gave 4 zeros to those, and when I changed it so the first one was 1, it got accepted

So you mean it is 1, 0, 1, 1?

For k=0, I don't print anything but a blank line. And if income is 0 then it is not a special case.

Can anybody provide with some test cases?

Posted: **Thu May 11, 2006 11:04 pm**

by **Darko**

Yes, that is what I meant, sorry.

Try those border cases, that's all I can think of (replace 28000 in the sample input with one of the values in the column 5 and see if you get a fee in the previous row)

And yes - I thought at the time that income 0 was special, but it's not.

Posted: **Sat May 13, 2006 11:43 am**

by **mamun**

Darko wrote:replace 28000 in the sample input with one of the values in the column 5 and see if you get a fee in the previous row

I should get the fee in the same row, isn't it? For example, if i replace 28000 by 29222 then I get

Smith 16 0.00

Smith 6 3.60

Smith 5 3.60

Smith 4 3.60

Smith 2 7.20

Can there be any precision problem? The only floating point values are the fees. I'm using double for them and dividing the value with 2.0 for halfing it.

I've really run out of ideas.

Posted: **Sat May 13, 2006 12:52 pm**

by **Darko**

Sorry, that's what I meant - I should stop doing that and just say "check border cases"

I am not sure, I just checked a couple of things:

- names don't start or end with whitespace, not sure if they contain any, I just consider the line to be a name.

- 32-bit ints are OK (I guess there is no Gates family after all)

I use double for fees and I divide by 2 as well.

It is probably one of those border cases, you probably covered them all, but I'll ask anyway - How do you check the range? If income is greater than the value in the last row it works? And - fee is paid for children 12 and younger, not 13. (I think I got that one right

)

I can't think of anything else

Posted: **Sat May 13, 2006 5:18 pm**

by **mamun**

This is how I check the range

Code: Select all

```
double search(int k,int salary){
for(int i=ROW-1;i>=0;i--)
if(salary>=table[i][k])
return fee[i];
}
```

Value of ROW is 12 of course and k is number of children - 1.

This is the first line for outputting

Code: Select all

`if(age[i]>=13) printf("%s %d 0.00\n",name,age[i]);`

I've used 32 bit signed integers and double only for the fees.

Really no idea.

Very frustrating.

Posted: **Thu Mar 27, 2008 2:42 pm**

by **x140l31**

I will response at me....

*Hello,*

can anyone help me
*if there's a family with 0 children? what I have to write? a blank line?*

*Leave a blank line after the output for each family.*

YES

### Re: 365 - Welfare Reform

Posted: **Fri Jul 08, 2016 12:04 pm**

by **metaphysis**

For guys who want to solve this problem:

(1)family name contain none space.

(2)there are test data which some children's age are same but with difrrent birthday, you should choose the "max" birthday as youngest, for example, there are three children with birthday(in real life, it seems impossible for a single monther family):

9 10 95

9 20 95

9 30 95

they are all 0 ages, but the third child is youngest.