結果

問題 No.432 占い(Easy)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-10-22 21:33:57
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 850 bytes
コンパイル時間 3,043 ms
コンパイル使用メモリ 85,764 KB
実行使用メモリ 56,688 KB
最終ジャッジ日時 2024-05-02 22:36:44
合計ジャッジ時間 7,533 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
41,032 KB
testcase_01 AC 101 ms
41,196 KB
testcase_02 AC 111 ms
41,220 KB
testcase_03 AC 117 ms
41,172 KB
testcase_04 RE -
testcase_05 WA -
testcase_06 AC 137 ms
41,300 KB
testcase_07 RE -
testcase_08 AC 123 ms
41,172 KB
testcase_09 AC 210 ms
43,208 KB
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 114 ms
40,968 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 211 ms
43,324 KB
権限があれば一括ダウンロードができます

ソースコード

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.nextLong()));
    }
  }
  public static String calc(Long num){
    String numStr = String.valueOf(num);
    while(Long.parseLong(numStr) > 9){
      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