cyphen156
백준-일반 수학 1 2720 세탁소 사장 동혁 본문
거스름 돈 계산기
제약사항
- Test T
- 0 < Max Val <= 5.00$ ==> 0 < Cent <= 500
- Quarter : 0.25$
- Dime : 0.1$
- Nickel : 0.05$
- Penny : 0.01$
- 받는 동전의 개수를 최소로
주의 사항
테스트 케이스 조건에 의해 거스름 돈이 0인 경우는 없다.
CPP풀이
세탁소 사장 동혁_2720.cpp
/**
* 백준 세탁소 사장 동혁_2720
* 거스름 돈 계산기
*
* 제한사항
*******************************************
* Test T *
* 0 < Max Val <= 5.00$ ==> 0 < Cent <= 500*
* Quarter : 0.25$ *
* Dime : 0.1$ *
* Nickel : 0.05 *
* Penny : 0.01$ *
* 받는 동전의 개수를 최소로 *
*******************************************
*
*
*
* 주의
* 테스트 케이스 조건에 의해 거스름 돈이 0인 경우는 없다.
*
* 풀이시간 20분
*/
#include <iostream>
using namespace std;
int main(void)
{
// T = TestCastCnt
int T = 0;
int divideValues[4] = { 25, 10, 5, 1 };
cin >> T;
for (int i = 0; i < T; ++i)
{
int inputValue;
cin >> inputValue;
int rtnValues[4] = { 0 };
for (int j = 0; j < size(divideValues); ++j)
{
int temp = inputValue / divideValues[j];
inputValue %= divideValues[j];
rtnValues[j] = temp;
cout << rtnValues[j] << " ";
}
cout << endl;
}
return 0;
}
모든 예제 코드의 소스파일은 제 개인 깃허브 레포지토리 에 있습니다.
Workspace/알고리듬 풀이 at main · cyphen156/Workspace
Studying . Contribute to cyphen156/Workspace development by creating an account on GitHub.
github.com
'컴퓨터공학 > 알고리듬 풀이' 카테고리의 다른 글
백준-일반 수학 1 2292 벌집 (0) | 2025.02.11 |
---|---|
백준-일반 수학 1 2903 중앙 이동 알고리즘 (1) | 2025.02.10 |
백준-일반 수학1 11005 진법변환2 (0) | 2025.02.07 |
백준-일반 수학1 2745 진법 변환 (0) | 2025.02.06 |
백준-2차원 배열 2563 색종이 (0) | 2025.02.04 |