結果

問題 No.432 占い(Easy)
ユーザー crazybbb3crazybbb3
提出日時 2016-10-29 13:56:36
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,135 bytes
コンパイル時間 1,912 ms
コンパイル使用メモリ 77,908 KB
実行使用メモリ 37,580 KB
最終ジャッジ日時 2024-05-03 15:45:40
合計ジャッジ時間 4,071 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
36,876 KB
testcase_01 AC 46 ms
36,860 KB
testcase_02 AC 44 ms
37,216 KB
testcase_03 AC 45 ms
37,048 KB
testcase_04 RE -
testcase_05 WA -
testcase_06 AC 46 ms
37,152 KB
testcase_07 RE -
testcase_08 AC 46 ms
37,104 KB
testcase_09 AC 56 ms
37,524 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 46 ms
36,748 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 70 ms
37,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int t = ni();
        long[] s = nla(t);
        for (int i = 0; i < t; i++) {
            calc(s[i]);
        }
    }

    void calc(long n) {
        while (n >= 10) {
            long tmp = 0;
            char[] ns = String.valueOf(n).toCharArray();
            long d = 1;
            for (int i = 0; i < ns.length - 1; i++) {
                int t = (ns[i] - '0') + (ns[i + 1] - '0');
                if (t >= 10) t -= 9;
                tmp += t * d;
                d *= 10;
            }
            n = tmp;
        }
        out.println(n);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0