#17801:


rexwu1104@gmail.com (黑雪公主 Black Lotus)

學校 : 新北市私立南山高級中學
編號 : 93041
來源 : [49.216.131.103]
最後登入時間 :
2024-06-06 19:28:43
d117. 10924 - Prime Words -- UVa10924 | From: [111.249.32.158] | 發表日期 : 2019-05-22 12:29

#include <iostream>
#include <string>
using namespace std;
int main()
{
  string a;
  while (cin >> a) {
    int b[26]={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}, c[26]={27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52},chr=a.size(), num=0, kk=0;
    for (int i=0;i<chr;i++) {
      if (a[i]>96) {
        num+=b[a[i]-96];
      }
      else {
        num+=c[a[i]-64];
      }
    }
    for (int i=1;i<=num;i++) {
      if (num%i==0) {
        kk+=1;
      }
    }
    kk>2 ? cout << "It is not a prime word." << endl : cout << "It is a prime word." << endl;
  }
}
 
ZeroJudge Forum