Skip to content

Commit 321e68e

Browse files
committed
[Bronze II] Title: 음계, Time: 64 ms, Memory: 11504 KB -BaekjoonHub
1 parent 824b14d commit 321e68e

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# [Bronze II] 음계 - 2920
2+
3+
[문제 링크](https://www.acmicpc.net/problem/2920)
4+
5+
### 성능 요약
6+
7+
메모리: 11504 KB, 시간: 64 ms
8+
9+
### 분류
10+
11+
구현
12+
13+
### 제출 일자
14+
15+
2025년 8월 1일 18:02:20
16+
17+
### 문제 설명
18+
19+
<p>다장조는 c d e f g a b C, 총 8개 음으로 이루어져있다. 이 문제에서 8개 음은 다음과 같이 숫자로 바꾸어 표현한다. c는 1로, d는 2로, ..., C를 8로 바꾼다.</p>
20+
21+
<p>1부터 8까지 차례대로 연주한다면 ascending, 8부터 1까지 차례대로 연주한다면 descending, 둘 다 아니라면 mixed 이다.</p>
22+
23+
<p>연주한 순서가 주어졌을 때, 이것이 ascending인지, descending인지, 아니면 mixed인지 판별하는 프로그램을 작성하시오.</p>
24+
25+
### 입력
26+
27+
<p>첫째 줄에 8개 숫자가 주어진다. 이 숫자는 문제 설명에서 설명한 음이며, 1부터 8까지 숫자가 한 번씩 등장한다.</p>
28+
29+
### 출력
30+
31+
<p>첫째 줄에 ascending, descending, mixed 중 하나를 출력한다.</p>
32+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
class Main {
5+
public static void main (String[] args) throws Exception {
6+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
StringTokenizer st = new StringTokenizer(br.readLine());
8+
int n = Integer.parseInt(st.nextToken());
9+
int n1 = Integer.parseInt(st.nextToken());
10+
int type = n1 - n;
11+
12+
if(type!=1&&type!=-1){
13+
System.out.println("mixed");
14+
} else {
15+
for(int i=2; i<8; i++){
16+
int expect = n1 + type;
17+
if(expect != Integer.parseInt(st.nextToken())){
18+
System.out.println("mixed");
19+
break;
20+
}
21+
n1 = expect;
22+
if(i==7){
23+
if(type > 0){
24+
System.out.println("ascending");
25+
} else {
26+
System.out.println("descending");
27+
}
28+
}
29+
}
30+
}
31+
32+
}
33+
}

0 commit comments

Comments
 (0)