[ABC422A]Stage Clear题解
Time Limit: 2 sec / Memory Limit: 1024 MiB
Score : 100 points
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 1st stage in the 1st world. The next stage after the j-th stage (1≤j≤8) in the i-th world (1≤i≤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 1st 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≤j≤8) in the i-th world (1≤i≤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.
讯飞听见 翻译
###问题陈述
高桥在玩游戏。这个游戏有八个世界,每个世界有八个阶段。
阶段有顺序,第一个阶段是 第 1 个世界中的 第 1 个阶段。 i 第 (1≤i≤8) 世界 j 第 (1≤j≤8) 阶段之后的下一阶段如下:
-当 j<8 时,
下一个阶段是第 i 世界的第 (j+1) 个阶段。-当 i<8,j=8 时,下一阶段是第 (i+1) 世界的 第 1 个阶段。
-当 i=8,j=8 时,没有下一阶段。
这个阶段是最后一个阶段。
第 i 世界 (1≤i≤8) 的第 j 级 (1≤j≤8) 的名称为 i - j 。
例如,第一级的名称是'1-1',最后一级的名称是'8-8'。给定Takahashi当前正在播放的舞台的艺名 S ,输出下一个舞台的艺名。
Constraints
- S is the stage name of one of the stages.
- S is not
8-8.
讯飞听见 翻译
###约束
-
S 是其中一个阶段的阶段名称。
-
S 不是“8-8”。
Input
The input is given from Standard Input in the following format:
S
讯飞听见 翻译
###输入
输入来自标准输入,格式如下:
S
Output
Output the stage name of the next stage.
讯飞听见 翻译
###输出
输出下一个阶段的阶段名称。
Sample Input 1
Copy
4-2
Sample Output 1
Copy
4-3
The next stage after the 2nd stage in the 4th world is the 3rd stage in the same world.
Sample Input 2
Copy
1-8
Sample Output 2
Copy
2-1
1-8 is the last stage in the 1st world, so the next stage is the 1st stage in the 2nd world.
Sample Input 3
Copy
3-3
Sample Output 3
Copy
3-4
思路
暴力
代码见下
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int main(){
cin>>s[0]>>s[1]>>s[2];
if(s[2]=='8'){
cout<<(char)(s[0]+1)<<"-"<<'1'<<endl;
}
else{
cout<<s[0]<<"-"<<(char)(s[2]+1)<<endl;
}
return 0;
}

浙公网安备 33010602011771号