본문 바로가기

Algorithm/기타(기업등)

[EPPER/13회 2번]거스름돈 계산(하-4)

728x90

 

 

 

#include <iostream>
#include <vector>

using namespace std;

vector<int> money = {50000,10000,5000,1000,500,100,50,10,8};

void solution(int m, int n) {
	  // 화폐 종류 개수, 총 화폐 개수 출력
		int change;
		int answer_1=0;
		int answer_2=0;
		int result=0;
	
		change = m-n;
		
		for(int i=0;i<money.size(); i++){
			result = change/money[i];
			change = change%money[i];
			
			if(result!=0) answer_1++; 
			
			answer_2 = answer_2+result;
		}

		
		cout<<answer_1<<" "<<answer_2;
		
		
	  return;
}

int main() {
	int m, n;
	cin >> m >> n;
	
	solution(m, n);
	
	return 0;
}
728x90