結果

問題 No.1458 Segment Function
ユーザー tentententen
提出日時 2021-04-13 10:04:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,560 bytes
コンパイル時間 1,989 ms
コンパイル使用メモリ 74,560 KB
実行使用メモリ 55,144 KB
最終ジャッジ日時 2023-09-11 14:04:16
合計ジャッジ時間 8,479 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,380 KB
testcase_01 AC 43 ms
49,436 KB
testcase_02 AC 43 ms
49,492 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 43 ms
49,432 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 97 ms
52,332 KB
testcase_10 WA -
testcase_11 AC 98 ms
52,460 KB
testcase_12 AC 106 ms
52,772 KB
testcase_13 AC 91 ms
51,868 KB
testcase_14 AC 94 ms
52,316 KB
testcase_15 AC 93 ms
52,172 KB
testcase_16 AC 94 ms
52,152 KB
testcase_17 AC 93 ms
52,160 KB
testcase_18 AC 128 ms
55,100 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 128 ms
54,276 KB
testcase_22 WA -
testcase_23 AC 45 ms
49,312 KB
testcase_24 WA -
testcase_25 AC 44 ms
49,660 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 95 ms
52,476 KB
testcase_32 AC 108 ms
52,672 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long value = 0;
        for (char c : sc.next().toCharArray()) {
            if (c == '-') {
                value++;
            } else {
                value += function(c - '0');
            }
        }
        String n = sc.next();
        int time = 6;
        if (n.length() == 1 && Integer.parseInt(n) < 6) {
            time = Integer.parseInt(n);
        }
        for (int i = 1; i < time; i++) {
            value = function(value);
        }
        System.out.println(value);
    }
    
    static int[] CONST = new int[]{6, 2, 5, 5, 4, 5, 6, 4, 7, 6};
    
    static int function(long x) {
        if (x < 10) {
            return CONST[(int)x];
        }
        int ans = 0;
        if (x > 0) {
            ans += CONST[(int)(x % 10)];
            x /= 10;
        }
        return ans;
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0