📄 c.cpp
字号:
// Problem C
// http://acm.uva.es/p/v109/10924.html
// Solution by semiconductor
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
using namespace std;
const char NUL = '\0';
char buf[21];
bool
Prime(int s)
{
int n = int(sqrt(s));
for ( int i = 2; i <= n; i++ ) if ( s % i == 0 ) return 0;
return 1;
}
int
main()
{
while ( scanf("%s", buf) != EOF ) {
int s = 0;
for ( int i = 0; buf[i]; i++ )
if ( islower(buf[i]) ) s += buf[i] - 'a' + 1;
else s += buf[i] - 'A' + 27;
if ( Prime(s) ) printf("It is a prime word.\n");
else printf("It is not a prime word.\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -