Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: APNICHANAN
Problemset: อะนาแกรม 2
Language: c
Time: 0.002 second
Submitted On: 2025-09-27 13:37:33
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
char str[2][10000];
scanf("%s %s", str[0], str[1]);
int a[2] = {0, 0}, b[2] = {0, 0}, c[2] = {0, 0}, d[2] = {0, 0}, e[2] = {0, 0}, f[2] = {0, 0}, g[2] = {0, 0}, h[2] = {0, 0}, cnt = 0;
for (int j = 0; j < strlen(str[0]); j++)
{
if (str[0][j] == 'A')
a[0]++;
else if (str[0][j] == 'B')
b[0]++;
else if (str[0][j] == 'C')
c[0]++;
else if (str[0][j] == 'D')
d[0]++;
else if (str[0][j] == 'E')
e[0]++;
else if (str[0][j] == 'F')
f[0]++;
else if (str[0][j] == 'G')
g[0]++;
else if (str[0][j] == 'H')
h[0]++;
}
printf("%d %d %d %d %d %d %d %d", a[0], b[0], c[0], d[0], e[0], f[0], g[0], h[0]);
printf("\n");
for (int j = 0; j < strlen(str[1]); j++)
{
if (str[1][j] == 'A')
a[1]++;
else if (str[1][j] == 'B')
b[1]++;
else if (str[1][j] == 'C')
c[1]++;
else if (str[1][j] == 'D')
d[1]++;
else if (str[1][j] == 'E')
e[1]++;
else if (str[1][j] == 'F')
f[1]++;
else if (str[1][j] == 'G')
g[1]++;
else if (str[1][j] == 'H')
h[1]++;
}
printf("%d %d %d %d %d %d %d %d", a[1], b[1], c[1], d[1], e[1], f[1], g[1], h[1]);
printf("\n");
if (a[0] != a[1])
{
printf("%.0f ", fabs(a[0] - a[1]));
cnt++;
}
else
{
printf("0 ");
}
if (b[0] != b[1])
{
printf("%.0f ", fabs(b[0] - b[1]));
cnt++;
}
else
{
printf("0 ");
}
if (c[0] != c[1])
{
printf("%.0f ", fabs(c[0] - c[1]));
cnt++;
}
else
{
printf("0 ");
}
if (d[0] != d[1])
{
printf("%.0f ", fabs(d[0] - d[1]));
cnt++;
}
else
{
printf("0 ");
}
if (e[0] != e[1])
{
printf("%.0f ", fabs(e[0] - e[1]));
cnt++;
}
else
{
printf("0 ");
}
if (f[0] != f[1])
{
printf("%.0f ", fabs(f[0] - f[1]));
cnt++;
}
else
{
printf("0 ");
}
if (g[0] != g[1])
{
printf("%.0f ", fabs(g[0] - g[1]));
cnt++;
}
else
{
printf("0 ");
}
if (h[0] != h[1])
{
printf("%.0f ", fabs(h[0] - h[1]));
cnt++;
}
else
{
printf("0 ");
}
printf("\n");
if (cnt > 3)
printf("no");
else
printf("anagram");
}