結果

問題 No.432 占い(Easy)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-10-22 21:39:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 3,102 ms
コンパイル使用メモリ 76,084 KB
実行使用メモリ 57,828 KB
最終ジャッジ日時 2024-11-23 17:42:47
合計ジャッジ時間 8,340 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise156 {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    for(int i = 0; i < number; i++){
      System.out.println(calc(sc.next()));
    }
  }
  public static String calc(String numStr){
    while(numStr.length() > 1){
      char[] numArray = new char[numStr.length()];
      for(int i = 0; i < numStr.length(); i++){
        numArray[i] = numStr.charAt(i);
      }
      String str = "";
      for(int i = 0; i < numStr.length() - 1; i++){
        int x = Character.getNumericValue(numArray[i]) + Character.getNumericValue(numArray[i + 1]);
        if(x > 9){
          x = x - 10 + 1;
        }
        str = str + String.valueOf(x);
      }
      numStr = str;
    }
    return numStr;
  }
}
0