eolymp
bolt
Try our new interface for solving problems
Problems

Cash machine

published at 3/17/18, 3:40:58 pm

Ilhom_Buriev, ти чув про массиви і цикли? -__-

published at 1/21/24, 7:20:56 pm

include <bits/stdc++.h>

using namespace std;

int main() { int n , say = 0; cin >> n;

int eskinazlar[] = {500, 200, 100, 50, 20, 10};

for (int i = 0; i < 6; ++i) 
{
    while(n >= eskinazlar[i]) 
    {
        n -= eskinazlar[i];
        say++;
    }
}

if (n != 0) 
{
    cout << "-1" << endl;
}
else 
{
    cout << say << endl;
}

}

published at 2/16/24, 12:36:15 pm

include <bits/stdc++.h>

using namespace std;

define io iosbase::syncwith_stdio(0);cin.tie(0);

define int long long

signed main() { io // code starts from here: int n, ans = 0; cin >> n; vector<int> v = {500,200,100,50,20,10}; for(int i: v){ if(n >= i){ ans+=n/i; n %= i; } } if(n != 0) cout << -1; else cout << ans; }