Programming/Baekjoon

백준 2720 c++

fishersheep 2022. 1. 21. 22:06
반응형

백준: 세탁소 사장 동혁

난이도: 브론즈3

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t;
	int c;
	cin >> t;
	
	vector < pair<pair<int, int>, pair<int, int>>>v(t);	//vector로 거스름돈의 수를 종류별로 저장

	for (int i = 0; i < t; i++)
	{
		cin >> c;
		if (c % 25 != c)	//0.25일 경우
		{	
			v[i].first.first += c / 25;	//vector에 사용될 동전의수를 더하고
			c = c % 25;	//나머지를 다시 c에 저장
		}
		if (c % 10 != c)	//0.10일 경우
		{	
			v[i].first.second += c / 10;
			c = c % 10;
		}
		if (c % 5 != c)		//0.05일 경우
		{
			v[i].second.first += c / 5;
			c = c % 5;
		}
		if (c % 1 != c)		//0.01일 경우
		{
			v[i].second.second += c / 1;
			c = c % 1;
		}

	}


	for (int i = 0; i < t; i++)
		cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second.first << " "
		<< v[i].second.second << '\n';

	return 0;
}
반응형

'Programming > Baekjoon' 카테고리의 다른 글

백준 2495 c++  (0) 2022.01.21
백준 5524 c++  (0) 2022.01.21
백준 10867 c++  (0) 2022.01.21
백준 7568 c++  (0) 2022.01.21
백준 1026 c++  (0) 2022.01.21