andy6804tw
7/15/2016 - 10:43 AM

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=21&problem=1865&mosmsg=Submission+received+

import java.util.Scanner;
 
public class test {
 
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner scn=new Scanner(System.in);
  while(scn.hasNext()){
   int tot=0,i=0;
   String str=scn.next();
   char arr[]=str.toCharArray();
   for(i=0;i<arr.length;i++){
    if(arr[i]&gt=65&&arr[i]&lt=90)tot+=arr[i]-38;
    else tot+=arr[i]-96;
   }
   for(i=2;i<tot;i++){
    if(tot%i==0)break;
   }
   if(tot==i||tot==1)System.out.println("It is a prime word.");
   else System.out.println("It is not a prime word.");
  }
   
 
 }
 
}
   
 /* 
    題目:Q10924: Prime Words
    作者:1010
    時間:西元 2016 年 6 月 */
}