洛谷 AT1898 题解

洛谷题目传送门 | AT 原题传送门

一道简单的打表题。

我们可以把题目给出的 1212 个音所对应的输入字符串先存好,然后直接字符串比对。

然后按照比对结果输出对应的音符即可解决本题。

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
string s,str;
string s1[20]={"","WBWBWWBWBWBW","BWBWWBWBWBWW","WBWWBWBWBWWB","BWWBWBWBWWBW","WWBWBWBWWBWB","WBWBWBWWBWBW","BWBWBWWBWBWW","WBWBWWBWBWWB","BWBWWBWBWWBW","WBWWBWBWWBWB","BWWBWBWWBWBW","WWBWBWWBWBWB"};//输入给出的颜色打表
string s2[20]={"","Do","#Do","Re","#Re","Mi","Fa","#Fa","So","#So","La","#La","Si"};//对应的音符打表
int main()
{
cin>>s;
for(int i=0;i<=11;i++)
{
str+=s[i];//截取输入前 12 位
}
for(int i=1;i<=12;i++)
{
if(str==s1[i])//字符串比对
{
cout<<s2[i]<<endl;
return 0;
}
}
return 0;
}

洛谷 AT1898 题解
https://blog.makerlife.top/post/solution-AT1898/
作者
Makerlife
发布于
2022年7月20日
许可协议