| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 154 | 3 | 3 | 2.174% |
Adam and Bill are playing cards. There are K cards in the deck, numbered 1 to K. The game consists of N rounds, during which each player is trying to score points. The winner is the one who has the most points at the end of the game.
Before each round, the deck is shuffled. During the first round players draw one card each. Then Bill shows his card, and Adam, knowing both cards, decides what action to take:
If Adam decides to show his card the round is won by the player who has the higher card. The number of points won is equal to the product of the numbers written on the cards.
For example, if Adam’s card shows 7 and Bill’s card shows 10, Bill wins this round and gets 70 points. The loser does not get any points for the round. Cards are then returned to the deck and shuffled, and the round ends.
If Adam decides to keep his card, Bill’s card is returned to the deck and the deck is shuffled. In the next round (if any are left) Bill will draw a new card while Adam will use the card he has decided to keep.
The game continues in this way. Bill always shows his card while Adam can choose what to do. The game ends after N rounds are played and both players sum their points up.
Let’s take an example when N = 4 and K = 10. The game could go like this:
Adam wants to win this game by as large margin as possible. Your task is to help him. Write a program that would play this game and make decisions for Adam. It has to make sure that Adam wins and try to win by as large margin as possible.
You have to implement the function atversti(a, b) with the following parameters:
a – the number that Adam drew.b – the number that Bill drew.The function has to return:
true, if Adam decides to show his card.false, if Adam decides to keep his card.Your program will be tested with a single test that has the limits K = 100 and N = 10 000 000. The order in which cards are drawn is generated by a random number generator so that drawing each card in the deck is equally likely.
Your function will be evaluated by the margin that Adam manages to win by. Let P = Adam’s margin/N:
Olympiad > Lithuanian Olympiad in Informatics > Lithuanian Olympiad in Informatics 2015/2016 > National Round (2) > 7-9 Classes 5번
Olympiad > Lithuanian Olympiad in Informatics > Lithuanian Olympiad in Informatics 2015/2016 > National Round (2) > 10-12 Classes 5번
C++17, C++20, C++17 (Clang), C++20 (Clang)