結果

問題 No.432 占い(Easy)
ユーザー takeya_okinotakeya_okino
提出日時 2017-10-27 21:55:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 74,396 KB
実行使用メモリ 61,016 KB
最終ジャッジ日時 2023-08-14 03:26:29
合計ジャッジ時間 9,135 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
56,736 KB
testcase_01 AC 122 ms
55,916 KB
testcase_02 AC 158 ms
56,880 KB
testcase_03 AC 167 ms
56,912 KB
testcase_04 AC 186 ms
58,972 KB
testcase_05 AC 168 ms
56,816 KB
testcase_06 AC 135 ms
55,680 KB
testcase_07 AC 183 ms
59,024 KB
testcase_08 AC 164 ms
57,268 KB
testcase_09 AC 214 ms
56,800 KB
testcase_10 AC 197 ms
57,252 KB
testcase_11 AC 231 ms
59,388 KB
testcase_12 AC 301 ms
59,656 KB
testcase_13 AC 300 ms
60,504 KB
testcase_14 AC 238 ms
59,444 KB
testcase_15 AC 165 ms
56,668 KB
testcase_16 AC 168 ms
57,100 KB
testcase_17 AC 298 ms
59,668 KB
testcase_18 AC 328 ms
61,016 KB
testcase_19 AC 310 ms
60,860 KB
testcase_20 AC 240 ms
59,836 KB
testcase_21 AC 247 ms
59,528 KB
testcase_22 AC 198 ms
57,168 KB
testcase_23 AC 203 ms
56,848 KB
testcase_24 AC 241 ms
57,096 KB
testcase_25 AC 213 ms
56,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int t = sc.nextInt();
    for(int i = 0; i < t; i++) {
      String s = sc.next();
      while(s.length() > 1) {
        String q = "";
        for(int j = 0; j < s.length() - 1; j++) {
          int a = Integer.parseInt(String.valueOf(s.charAt(j)));
          int b = Integer.parseInt(String.valueOf(s.charAt(j + 1)));
          int c = a + b;
          if(c > 9) c = (c % 10) + 1;
          q += c; 
        }
        s = q;
      }
      int ans = Integer.parseInt(String.valueOf(s.charAt(0)));
      System.out.println(ans);
    }
  }
}
0