CF784D Touchy-Feely Palindromes

Link

洛谷 & Codeforces

Tag

洛谷:字符串

Codeforces:implementation

Difficulty Level

洛谷: 入门 \color{#fe4c61}{入门} 入门

Codeforces: 1900 \color{#9d3dcf}{1900} 1900

Solution

这在 CF 上是 April Fools Contest 题目,所以我怀疑 1900 \color{#9d3dcf}{1900} 1900 的题目难度也是 fool (

当时菜的要死,所以没做出来(虽然现在也很菜)。

因为翻转的时候要把盲文字符整体翻转,所以对应的数字盲文应该翻转,因为只有十个数,所以直接手玩,可以得出对应表(无对应的为 − 1 -1 1):

原数对应数
08
1-1
2-1
33
46
59
64
77
80
95

而且我们可以直接算出位置 x x x 的对应位为 l − x + 1 l-x+1 lx+1 l l l 为数字串长度)。

Code

#include<iostream>
#include<cstdio>
#include<cstring>
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;
}

Submission

Codeforces submission

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值