紫书——Ancient Cipher UVA - 1339

版权声明: https://blog.csdn.net/a673953508/article/details/81046338

题目:这道题目真心觉得是烂题,可以说题目大意说得不明不白,加密的方式与题意没有任何关联

只要你找出每个字母出现的次数和后一次出现的次数有关联就能YES

比如MDMD和CCDD最后都是两次就YES了

代码如下:

#include <bits/stdc++.h>
using namespace std;

int main() {
	char str1[105],str2[105];
	
	while(~scanf("%s%s",str1,str2)) {
		int len=strlen(str1);
		int cnt1[26]= {0},cnt2[26]= {0};
		
		for(int i=0; i<len; i++) {
			cnt1[str1[i]-'A']++;
			cnt2[str2[i]-'A']++;
		}
		
		sort(cnt1,cnt1+26);
		sort(cnt2,cnt2+26);
		
		int ok=1;
		for(int i=1; i<26; i++)
			if(cnt1[i]!=cnt2[i]) {
				printf("NO\n");
				ok = 0;
				break;
			}

		if(ok)	printf("YES\n");
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/a673953508/article/details/81046338