結果
問題 |
No.1458 Segment Function
|
ユーザー |
![]() |
提出日時 | 2021-04-13 10:04:43 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,560 bytes |
コンパイル時間 | 1,876 ms |
コンパイル使用メモリ | 78,024 KB |
実行使用メモリ | 54,588 KB |
最終ジャッジ日時 | 2024-06-29 04:18:16 |
合計ジャッジ時間 | 6,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 17 |
ソースコード
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(); } }