eolymp
bolt
Try our new interface for solving problems
dərc olunub 17.03.18 15:40:58

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

dərc olunub 21.01.24 19:20:56

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;
}

}

dərc olunub 16.02.24 12:36:15

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; }