티스토리 뷰
반응형
백준 2480번 주사위 세개
https://www.acmicpc.net/problem/2480
2480번: 주사위 세개
1에서부터 6까지의 눈을 가진 3개의 주사위를 던져서 다음과 같은 규칙에 따라 상금을 받는 게임이 있다. 같은 눈이 3개가 나오면 10,000원+(같은 눈)×1,000원의 상금을 받게 된다. 같은 눈이 2개
www.acmicpc.net



정답 코드
#include<iostream>
using namespace std;
int main() {
int flag = 0,index=0;
int arr[3] = { 0, };
for (int x = 0; x < 3; x++)
cin >> arr[x];
if (arr[0] == arr[1] && arr[1] == arr[2] && arr[0] == arr[2])
cout << 10000 + arr[0] * 1000;
else if (arr[0]==arr[1]&&arr[1]!=arr[2])
cout << 1000 + arr[0] * 100;
else if (arr[0] == arr[2] && arr[1] != arr[2])
cout << 1000 + arr[0] * 100;
else if (arr[0] != arr[1] && arr[1] == arr[2])
cout << 1000 + arr[2] * 100;
else {
int max = 0;
for (int x = 0; x < 3; x++) {
if (max < arr[x])
max = arr[x];
}
cout << max * 100;
}
}
반응형
'Algorithm > BOJ' 카테고리의 다른 글
백준 2525번 C++ (0) | 2023.08.08 |
---|---|
백준 2501번 C++ (0) | 2023.08.08 |
백준 2475번 C++ (0) | 2023.08.07 |
백준 2468번 C++ (0) | 2023.08.07 |
백준 2448번 C++ (0) | 2023.08.07 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 백준 풀이
- CSS
- 백준
- 세그먼트 트리
- 유클리드 호제법
- C++ Stack
- 카운팅 정렬
- Do it!
- C++
- js
- BFS
- HTML5
- 자바스크립트
- java
- 우선순위 큐
- html
- 알고리즘
- 투 포인터
- 유니온 파인드
- 자료구조
- 이분 매칭
- 스택
- 반복문
- 자바
- DP
- 스프링 부트 crud 게시판 구현
- 알고리즘 공부
- DFS
- 에라토스테네스의 체
- c++ string
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함