結果

問題 No.432 占い(Easy)
ユーザー takeya_okinotakeya_okino
提出日時 2017-10-27 21:55:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 77,128 KB
実行使用メモリ 59,544 KB
最終ジャッジ日時 2024-05-01 16:17:58
合計ジャッジ時間 8,387 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,080 KB
testcase_01 AC 118 ms
53,776 KB
testcase_02 AC 139 ms
54,816 KB
testcase_03 AC 154 ms
54,816 KB
testcase_04 AC 173 ms
55,140 KB
testcase_05 AC 154 ms
55,020 KB
testcase_06 AC 135 ms
53,880 KB
testcase_07 AC 172 ms
55,084 KB
testcase_08 AC 141 ms
54,484 KB
testcase_09 AC 202 ms
54,984 KB
testcase_10 AC 179 ms
55,256 KB
testcase_11 AC 201 ms
57,880 KB
testcase_12 AC 252 ms
58,316 KB
testcase_13 AC 260 ms
58,304 KB
testcase_14 AC 210 ms
57,880 KB
testcase_15 AC 134 ms
54,468 KB
testcase_16 AC 160 ms
54,980 KB
testcase_17 AC 269 ms
58,252 KB
testcase_18 AC 303 ms
59,544 KB
testcase_19 AC 283 ms
59,528 KB
testcase_20 AC 229 ms
57,992 KB
testcase_21 AC 259 ms
58,108 KB
testcase_22 AC 213 ms
55,436 KB
testcase_23 AC 204 ms
54,988 KB
testcase_24 AC 220 ms
55,112 KB
testcase_25 AC 201 ms
54,700 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