Bonapity Gym - 101028B

A group of junior programmers are attending an advanced programming camp, where they learn very difficult algorithms and programming techniques! Near the center in which the camp is held, is a professional bakery which makes tasty pastries and pizza. It is called 'Bonabity'... or 'Ponapety'... or 'Ponabity'... Actually no one knows how to spell this name in English, even the bakery owner doesn't, and the legends say that Arabs always confuse between 'b' and 'p', and also between 'i' and 'e', so 'b' for them is just the same as 'p', and 'i' for them is just the same as 'e', they also don't care about letters' cases (uppercase and lowercase for a certain letter are similar). For example, the words 'Ponabity' and 'bonabety' are considered the same. You are given two words including only upper case and lower case English letters, and you have to determine whether the two words are similar in Arabic.

Input

The input consists of several test cases. The first line of the input contains a single integer T, the number of the test cases. Each of the following T lines represents a test case and contains two space-separated strings (each one consists of only upper case and lower case English letters and its length will not exceed 100 characters)

 Output

For each test case print a single line: 'Yes' if the words are similar in Arabic and 'No' otherwise.

 

Example

Input

4
Ponabity bonabety
barbie barpee
abcabc apcap
abc apcd

Output

Yes
Yes
No
No

1、字符串的处理看起来很简单的, 统一 为大写字母。

2、strcmp 挺好用的, 尽管可能比较慢。

3、这题看似很难, 其实虚有其表。

 

 噢:代码是队友写的 , 转载声明 链接地址

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#define INF 0x3f3f3f3f
using namespace std;

void f(char *s)      //统一大小写, 转化P、I;
{
    for( int i = 0; i < strlen(s); i++)
    {
        if(s[i] >= 97 && s[i] <= 123)
            s[i] -= 32;
        if(s[i] == 'P')
            s[i] = 'B';
        else if(s[i] == 'I')
            s[i] = 'E';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    int t;
    char s1[100], s2[100];
    cin >> t;
    while(t--)
    {
        cin >> s1 >> s2;
        f(s1);
        f(s2);
        if(!strcmp(s1, s2))
            cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值