365 - Welfare Reform
Moderator: Board moderators
365 - Welfare Reform
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?
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?
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.
What's the age of following children?
9 1 95
9 2 95
8 30 95
8 31 95
Where is the trick? Does name of family contain whitespace? I tried that also.
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?Children in the same family will not share birthdays.
What's the age of following children?
9 1 95
9 2 95
8 30 95
8 31 95
Thanks mamun for the hint ![:)](./images/smilies/icon_smile.gif)
My WA gave 4 zeros to those, and when I changed it so the first one was 1, it got accepted![:)](./images/smilies/icon_smile.gif)
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.
![:)](./images/smilies/icon_smile.gif)
My WA gave 4 zeros to those, and when I changed it so the first one was 1, it got accepted
![:)](./images/smilies/icon_smile.gif)
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.
Nice to see my hint helped you to get AC.
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?
![:D](./images/smilies/icon_biggrin.gif)
So you mean it is 1, 0, 1, 1?Darko wrote:My WA gave 4 zeros to those, and when I changed it so the first one was 1, it got accepted
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?
I should get the fee in the same row, isn't it? For example, if i replace 28000 by 29222 then I getDarko 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
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.
![:cry:](./images/smilies/icon_cry.gif)
Sorry, that's what I meant - I should stop doing that and just say "check border cases" ![:)](./images/smilies/icon_smile.gif)
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![:(](./images/smilies/icon_frown.gif)
![:)](./images/smilies/icon_smile.gif)
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
![:)](./images/smilies/icon_smile.gif)
I can't think of anything else
![:(](./images/smilies/icon_frown.gif)
This is how I check the range
Value of ROW is 12 of course and k is number of children - 1.
This is the first line for outputting
I've used 32 bit signed integers and double only for the fees.
Really no idea.
Very frustrating.
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];
}
This is the first line for outputting
Code: Select all
if(age[i]>=13) printf("%s %d 0.00\n",name,age[i]);
Really no idea.
![:evil:](./images/smilies/icon_evil.gif)
I will response at me....
Hello,
can anyone help me![:P](./images/smilies/icon_razz.gif)
if there's a family with 0 children? what I have to write? a blank line?
YES
Hello,
can anyone help me
![:P](./images/smilies/icon_razz.gif)
Code: Select all
removed get AC
Leave a blank line after the output for each family.
YES
-
- Experienced poster
- Posts: 139
- Joined: Wed May 18, 2011 3:04 pm
Re: 365 - Welfare Reform
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.
(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.
metaphysis: http://uhunt.onlinejudge.org/id/95895
My solutions for UVa problems: https://github.com/metaphysis/Code.
My solutions for UVa problems: https://github.com/metaphysis/Code.