Saturday, March 19, 2022

Minimum number of coins

 Chef has infinite coins in denominations of rupees 

and rupees

.

Find the minimum number of coins Chef needs, to pay exactly

rupees. If it is impossible to pay rupees in denominations of rupees and only, print

.

Input Format

  • First line will contain
  • , number of test cases. Then the test cases follow.
  • Each test case contains of a single integer
    • .

    Output Format

    For each test case, print a single integer - the minimum number of coins Chef needs, to pay exactly

    rupees. If it is impossible to pay rupees in denominations of rupees and only, print

    .

    Constraints

    Subtasks

    • Subtask 1 (100 points): Original constraints.

    Sample Input 1

    3
    50
    15
    8
    

    Sample Output 1

    5
    2
    -1
    

    Explanation

    Test Case

    : Chef would require at least coins to pay rupees. All these coins would be of rupees

    .

    Test Case

    : Chef would require at least coins to pay rupees. Out of these, coin would be of rupees and coin would be of rupees

    .

    Test Case

    : Chef cannot pay exactly rupees in denominations of rupees and only.

    No comments:

    Post a Comment

    मुझे दिल में बसाना आसान नहीं....

    पता है Recently i realised की मुझे दिल में बसाना आसान नहीं है बात-बात पे चिढ़ जाती हूं मैं दिल लगा लूं एक बार तो फिर ज़िद पे अड़...