Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
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
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 19602번 Dog Treats 본문

YJ/C++

[백준/BOJ/C++] 19602번 Dog Treats

Team DAON 2021. 10. 22. 14:18

[문제]

Barley the dog loves treats. At the end of the day he is either happy or sad depending on the number and size of treats he receives throughout the day. The treats come in three sizes: small, medium, and large. His happiness score can be measured using the following formula:

 

1 × S + 2 × M + 3 × L

 

where S is the number of small treats, M is the number of medium treats and L is the number of large treats.

If Barley’s happiness score is 10 or greater then he is happy. Otherwise, he is sad. Determine whether Barley is happy or sad at the end of the day.

 

[입력]

There are three lines of input. Each line contains a non-negative integer less than 10. The first line contains the number of small treats, S, the second line contains the number of medium treats, M, and the third line contains the number of large treats, L, that Barley receives in a day.

 

[출력]

If Barley’s happiness score is 10 or greater, output happy. Otherwise, output sad.

 

[Source Code]

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int score = 0;

	for(int i = 1; i <= 3; i++){
		int input;
		cin >> input;
		score += input * i;
	}
	
	if(score < 10)
		cout << "sad";
	else
		cout << "happy";
}

[결과 화면]