usaco-1-1
Since I don’t have much experience in coding and I just do it for fun, I hope my code can bring you some happiness and understnading here…
This is just USACO 1.1, easy. But the problem afterwards are hard…
Prob 0. 1 + 1 = 2
Just used for testing the input and output form of usaco testing system.
1 | /* |
Prob 1. Your Ride Is Here
I wrote some not-elegant code for this problem. Anyway, I solved it after all.
- We transfer the letters into numbers.
- Then get the product $mod$ 47.
- If the result is equal to 27, output ‘go’, else output ‘stay’.
1 | /* |
Prob 2. Greedy Gift Givers
A little complicated, but we can still see it through easily.
- We need to establish a relationship between name array and money amount array, so I create a function called
find_name
. - Since all the money should be given in an integer form. Then I created a function called
give_over
andleft_over
.left_over
returns how much you left after you give off money.give_over
returns how much you need to give off to others.
- So use
find_name
to locate the giver and the given, then usegive_over
andleft_over
to determine the amount of money change.
1 | /* |
Prob 3. Friday the Thirteenth
This is a easy problem. Just match the days and $mod$ 7 to check and count the times.
1 | /* |