-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVA 10924.cpp
47 lines (47 loc) · 911 Bytes
/
UVA 10924.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
#include<string.h>
int main()
{
int numbers[2000]= {0},i,j,l,sum;
numbers[0]=1;
for(i=4; i<2000; i+=2)
{
numbers[i]=1;
}
for(i=3; i<45; i+=2)
{
if(numbers[i]==0)
{
for(j=i*i; j<2000; j+=i)
{
numbers[j]=1;
}
}
}
char c[25];
while(gets(c))
{
sum=0;
l=strlen(c);
for(i=0;i<l;i++)
{
if(c[i]>='a'&&c[i]<='z')
{
sum=sum+(c[i]-96);
}
if(c[i]>='A'&&c[i]<='Z')
{
sum=sum+(c[i]-38);
}
}
if(numbers[sum]==0)
{
printf("It is a prime word.\n");
}
else
{
printf("It is not a prime word.\n");
}
}
return 0;
}