結果

問題 No.1458 Segment Function
ユーザー 小野寺健小野寺健
提出日時 2021-05-01 12:05:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 3,207 ms
コンパイル使用メモリ 77,908 KB
実行使用メモリ 43,876 KB
最終ジャッジ日時 2024-04-20 17:43:08
合計ジャッジ時間 10,481 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
40,136 KB
testcase_01 AC 103 ms
40,052 KB
testcase_02 AC 109 ms
40,984 KB
testcase_03 AC 116 ms
41,344 KB
testcase_04 AC 109 ms
41,176 KB
testcase_05 AC 112 ms
41,428 KB
testcase_06 AC 99 ms
40,416 KB
testcase_07 AC 110 ms
41,472 KB
testcase_08 AC 196 ms
43,120 KB
testcase_09 AC 196 ms
42,668 KB
testcase_10 AC 192 ms
42,768 KB
testcase_11 AC 215 ms
43,104 KB
testcase_12 AC 194 ms
43,236 KB
testcase_13 AC 181 ms
42,604 KB
testcase_14 AC 188 ms
42,620 KB
testcase_15 AC 185 ms
42,892 KB
testcase_16 AC 180 ms
42,832 KB
testcase_17 AC 179 ms
42,844 KB
testcase_18 AC 241 ms
43,620 KB
testcase_19 AC 222 ms
43,120 KB
testcase_20 AC 240 ms
43,876 KB
testcase_21 AC 237 ms
43,160 KB
testcase_22 AC 210 ms
43,376 KB
testcase_23 AC 99 ms
39,416 KB
testcase_24 AC 197 ms
42,736 KB
testcase_25 AC 107 ms
40,600 KB
testcase_26 AC 215 ms
43,256 KB
testcase_27 AC 203 ms
43,132 KB
testcase_28 AC 112 ms
40,992 KB
testcase_29 AC 199 ms
43,628 KB
testcase_30 AC 198 ms
42,308 KB
testcase_31 AC 188 ms
42,944 KB
testcase_32 AC 209 ms
42,908 KB
testcase_33 AC 206 ms
43,100 KB
testcase_34 AC 201 ms
43,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class No1458 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String P = scan.next();
		String N = scan.next();
		scan.close();
		
		int[] T = new int[] {6, 2, 5, 5, 4, 5, 6, 4, 7, 6};
		
		int n = N.length() > 1 ? 10 : Integer.valueOf(N);
		if (n == 0) {
			System.out.println(P);
			return;
		}
		int p = 0, i = 0;
		if (P.charAt(0) == '-') {
			p++;
			i++;
		}
		for (; i < P.length(); i++) {
			p += T[P.charAt(i) - '0'];
		}
		for (i=0; i < n-1; i++) {
			if (p == 4 || p == 5 || p == 6) {
				break;
			}
			int np = 0;
			while (p > 0) {
				np += T[p % 10];
				p /= 10;
			}
			p = np;
		}
		System.out.println(p);
	}

}
0