Problems
Cash machine
Ilhom_Buriev, ти чув про массиви і цикли? -__-
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;
}
}
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; }