본문 바로가기
백준

C++ 5585 거스롬돈

by 안선생 2023. 2. 11.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<vector>
using namespace std;
 
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
 
    int n;
    cin >> n;
    int a = 0;
    int result = 1000-n;
    
        a += result /500 ;
        result %= 500;
 
        a += result / 100;
        result %= 100;
 
        a += result / 50;
        result %= 50;
 
        a += result / 10;
        result %= 10;
 
        a += result / 5;
        result %= 5;
 
        a += result / 1;
        result %= 1;
 
        cout << a;
 
 
 
 
}
 
 
cs

 

https://www.acmicpc.net/problem/5585

 

5585번: 거스름돈

타로는 자주 JOI잡화점에서 물건을 산다. JOI잡화점에는 잔돈으로 500엔, 100엔, 50엔, 10엔, 5엔, 1엔이 충분히 있고, 언제나 거스름돈 개수가 가장 적게 잔돈을 준다. 타로가 JOI잡화점에서 물건을 사

www.acmicpc.net

 

'백준' 카테고리의 다른 글

C++ 10610 30  (0) 2023.02.11
C++ 1439 뒤집기  (0) 2023.02.11
C++ 1931 회의실 배정  (0) 2023.02.10
C++ 13305 주요소  (0) 2023.02.10
C++ 13305 잃어버린 괄호  (0) 2023.02.10