1、题目类型:哈希表。
2、解题思路:水题。
3、注意事项:哈希公式。
4、实现方法:
#include
<
iostream
>
using namespace std;
#define Max 26
int anum[Max],bnum[Max];
int main()
{
int i,ahash,bhash;
char ch;
while ((ch = getchar()) != ' \n ' )
++ anum[ch - ' A ' ];
while ((ch = getchar()) != ' \n ' )
++ bnum[ch - ' A ' ];
for (i = 0 ;i < Max;i ++ )
{
ahash += anum[i] * anum[i];
bhash += bnum[i] * bnum[i];
}
if (ahash == bhash)
cout << " YES " << endl;
else
cout << " NO " << endl;
return 1 ;
}
using namespace std;
#define Max 26
int anum[Max],bnum[Max];
int main()
{
int i,ahash,bhash;
char ch;
while ((ch = getchar()) != ' \n ' )
++ anum[ch - ' A ' ];
while ((ch = getchar()) != ' \n ' )
++ bnum[ch - ' A ' ];
for (i = 0 ;i < Max;i ++ )
{
ahash += anum[i] * anum[i];
bhash += bnum[i] * bnum[i];
}
if (ahash == bhash)
cout << " YES " << endl;
else
cout << " NO " << endl;
return 1 ;
}