Hungry Ari Buys a Sandwich
InterviewTime limit1sMemory limit1024 MB
Given a sandwich price S and Kugi's money M, decide whether Ari can pay alone, needs Kugi's coins, or cannot pay even with Kugi's help.
- Level
Easy3 of 10
- Topics
- Bit manipulation, Math
- Solved
- No attempts yet
Problem
"두리" is a country. Its coins come in ten denominations: 1, 2, 4, 8, 16, 32, 64, 128, 256, and 512 won. Ari, a citizen of Duri, has one coin of each denomination, ten coins in total.
Ari goes to a bakery to buy a sandwich. The bakery has no change, so the sandwich price won must be paid exactly, or it cannot be bought. While Ari is working out the payment, Ari's friend Kugi walks into the bakery. Kugi has one coin each of some of the ten denominations (not necessarily all of them), and the coins total won. Kugi can lend any part or all of that money to Ari. However, Ari will not borrow while keeping some of Ari's own money. Ari must spend all of Ari's own coins first and then borrow only the shortfall from Kugi.
Ari wants to greet Kugi differently depending on the situation. Find what Ari should say to Kugi.
Input
The first line contains the sandwich price (1 ≤ ≤ 2048) and the amount (1 ≤ ≤ 1023) that Kugi has, separated by a space.
Output
If Ari can buy the sandwich with Ari's own money alone, print No thanks. If Ari needs Kugi's help to buy it, print Thanks. If the sandwich cannot be bought even when Kugi lends all of the money, print Impossible.