洛谷 & Codeforces
洛谷:字符串
Codeforce:implementation
洛谷: 入门 \color{#fe4c61}{入门} 入门
Codeforces: 1900 \color{#9d3dcf}{1900} 1900
这在 CF 上是 April Fools Contest 题目,所以我怀疑 1900 \color{#9d3dcf}{1900} 1900 的题目难度也是 fool (
当时菜的要死,所以没做出来(虽然现在也很菜)。
因为翻转的时候要把盲文字符整体翻转,所以对应的数字盲文应该翻转,因为只有十个数,所以直接手玩,可以得出对应表(无对应的为 − 1 -1 −1):
原数 | 对应数 |
---|---|
0 | 8 |
1 | -1 |
2 | -1 |
3 | 3 |
4 | 6 |
5 | 9 |
6 | 4 |
7 | 7 |
8 | 0 |
9 | 5 |
而且我们可以直接算出位置 x x x 的对应位为 l − x + 1 l-x+1 l−x+1 ( l l l 为数字串长度)。
#include
#include
#include
using namespace std;
int a[10]={8,-1,-1,3,6,9,4,7,0,5};
char s[20];
int main()
{
scanf("%s",s+1);
int l=strlen(s+1);
for(int i=1;i<=l;i++)
if(s[l-i+1]-'0'!=a[s[i]-'0'])
{
printf("No");
return 0;
}
printf("Yes");
return 0;
}