Canadian Computing Competition: 2009 Stage 1, Junior #2
Fishing habitat and fish species are a resource that must be carefully managed to ensure that they will be there for the future. Accordingly, fishing limits have been established for a particular river based on the population of each species. Specifically, points are associated with the fish caught and the total points you catch must be less than or equal to the points allowed for that river.
As an example, suppose each brown trout counts as points, each northern pike counts as
points and each yellow pickerel counts as
points, and the total points allowed must be less than or equal to
. One acceptable catch could consist of
brown trout and
northern pike, but, other combinations would also be allowed.
Your job is to write a program to input the points allocated for a river, and find how many different ways an angler who catches at least one fish can stay within his/her limit.
Input Specification
You will be given integers, one per line, representing trout points, pike points, pickerel points, and total points allowed in that order.
You can assume that each integer will be greater than and less than or equal to
.
Output Specification
For each different combination of fish caught, output the combination of brown trout, northern pike, and yellow pickerel in that order. The combinations may be listed in any order. The last line of output should display the total number of unique ways to catch fish within the established limit.
Sample Input
1
2
3
2
Sample Output
1 Brown Trout, 0 Northern Pike, 0 Yellow Pickerel
2 Brown Trout, 0 Northern Pike, 0 Yellow Pickerel
0 Brown Trout, 1 Northern Pike, 0 Yellow Pickerel
Number of ways to catch fish: 3
Comments
I realized that I was supposed to use a loop~ "oops"
Can someone tell me what I'm doing wrong?
this is honestly a pretty bad example bc it doesnt show how the answers would be ordered if 2 fish were caught at once
I got it wrong for missing a comma. Make sure you read the output carefully!
If you use python, it's a good idea to use a nested for loop or your code might not include "1 Brown Trout, 1 Northern Pike, 1 Yellow Pickerel" if you input 1, 1, 1, and 3.
What's wrong with my code?!!! It works perfectly in eclipse but gets WA here? HELP ME PLEZ!
um, your code doesn't seem right at this line
Thanks!
how do you check other people's code? I'd like to help but idk how...
You have to solve the problem first...
thanks!
When I use my code on NetBeans it works perfectly fine but when I submit it, the answer prints the first line and then only prints the amount of brown trout on second line and nothing else.
It shows you a clipped version of your output.
When you out put the same answers but in a different order :/