Minimum Number of Coins Solution || Codechef March Lunchtime 2022

        

Minimum Number of Coins Solution 

Codechef March Lunchtime 2022
Problem Code : MINCOINS

Solution :

#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;

void solve()
{
    ll x;
    cin >> x;
    if (x % 5)
    {
        cout << "-1\n";
    }
    else
    {
        ll ten = x / 10;
        cout << ten + (x - ten * 10) / 5 << "\n";
    }
}

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Comments