結果
問題 | No.539 インクリメント |
ユーザー | takeya_okino |
提出日時 | 2019-10-02 19:24:48 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,356 bytes |
コンパイル時間 | 2,254 ms |
コンパイル使用メモリ | 79,792 KB |
実行使用メモリ | 58,756 KB |
最終ジャッジ日時 | 2024-04-14 08:59:16 |
合計ジャッジ時間 | 4,815 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 436 ms
58,312 KB |
testcase_02 | AC | 406 ms
58,180 KB |
testcase_03 | WA | - |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); String line = sc.nextLine(); String s1 = ""; String s2 = ""; for(int i = 0; i < T; i++) { String s = sc.nextLine(); char[] ss = s.toCharArray(); int p = 0; int increment = 1; int k = 0; int ind = 0; for(int j = s.length() - 1; j >= 0; j--) { String str = String.valueOf(s.charAt(j)); int t = -1; try { t = Integer.parseInt(str); } catch(NumberFormatException e) { } if(t == -1) { if(p == 0) { } else { if(increment == 1) { k = 1; ind = j + 1; break; } } } else { p = 1; if(increment == 1) { if(t == 9) { ss[j] = "0".charAt(0); } else { ss[j] = (String.valueOf(t + 1)).charAt(0); break; } } } } if(k == 0) { System.out.println(new String(ss)); } else { String sa = new String(ss); s1 = sa.substring(0, ind); s2 = sa.substring(ind, s.length()); System.out.println(s1 + "1" + s2); } } } }