Python Forum
Any help would be appreciated
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any help would be appreciated
#1
PROBLEM:

Joel has a collection of unique coins. He would like to use them to pay a certain amount of money, but he wouldn’t want to part with more than two of his coins for this purpose. Write a program which determines which amounts are possible to pay with exactly two of his coins.

You will get marks on this question depending on how efficient your program is. 3/5 is still a good score, as it’s not an easy question!

Input

The first line of the input contains 𝑛
n
, the number of coins in Joel’s collection.

Each of the following 𝑛
n
lines contain one number – the value in pence of a single coin.

The following line contains 𝑄
Q
, the number of questions. Note that 𝑄
Q
is at most 5.

Each of the final 𝑄
Q
lines contain one amount which Joel wants to pay.

Output

For each of the questions, output whether it is possible to pay the amount required using exactly two coins from Joel’s collection. Paying with one coin is boring and doesn’t count!

Output 𝑄
Q
lines, each containing YES or NO

--------------------------------------------------

WHAT I HAVE SO FAR:
Reply
#2
you forgot to add the 'What I have so far' part.
nilamo likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help appreciated elperex 8 4,242 Aug-22-2019, 09:50 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020