fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
AtCoder Beginner Contest 422-A (C++) Stage Clear
최초 업로드: 2025-09-07 06:57:50
최근 수정 시간: 2025-09-07 06:58:03
게시자: rlatjwls3333
카테고리: Atcoder
조회수: 4
# A - Stage Clear [문제 링크](https://atcoder.jp/contests/abc422/tasks/abc422_a) ## Problem Statement Takahashi is playing a game. This game has eight worlds, and each world has eight stages. The stages have an order, and the first stage is the \$1\$st stage in the \$1\$st world. The next stage after the \$j\$-th stage \$(1 \le j \le 8)\$ in the \$i\$-th world \$(1 \le i \le 8)\$ is as follows: * When \$j < 8\$, the next stage is the \$(j+1)\$-th stage in the \$i\$-th world. * When \$i < 8,; j = 8\$, the next stage is the \$1\$st stage in the \$(i+1)\$-th world. * When \$i = 8,; j = 8\$, there is no next stage. This stage is the last stage. The name of the \$j\$-th stage \$(1 \le j \le 8)\$ in the \$i\$-th world \$(1 \le i \le 8)\$ is \$i\$-\$j\$. For example, the name of the first stage is `1-1`, and the name of the last stage is `8-8`. Given the stage name \$S\$ of the stage Takahashi is currently playing, output the stage name of the next stage. ## Constraints * \$S\$ is the stage name of one of the stages. * \$S\$ is not `8-8`. ## Input The input is given from Standard Input in the following format: $S$ ## Output Output the stage name of the next stage. ## 풀이 j가 8이 넘으면 j를 1로 만들고 i를 증가시켜주었다. ``` c++ #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int a, b; char ch; cin >> a >> ch >> b; if(++b==9) a++, b=1; cout << a << '-' << b; } ```