結果
問題 |
No.539 インクリメント
|
ユーザー |
![]() |
提出日時 | 2017-09-23 19:17:29 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,336 bytes |
コンパイル時間 | 2,716 ms |
コンパイル使用メモリ | 90,492 KB |
実行使用メモリ | 115,948 KB |
最終ジャッジ日時 | 2024-11-14 04:21:44 |
合計ジャッジ時間 | 9,858 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 1 TLE * 2 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++) { String s = sc.next(); int flg = 0; int keizoku = 0; int kuriage = 0; int hatsu = 0; String ans = ""; for(int j = s.length() - 1; j >= 0; j--) { String str = String.valueOf(s.charAt(j)); if(flg == 0) { try{ int d = Integer.parseInt(str); keizoku = 1; if(hatsu == 0) { hatsu = 1; if(d + 1 < 10) { ans = (d + 1) + ans; flg = 1; } else { ans = "0" + ans; kuriage = 1; } } else { if(d + kuriage < 10) { ans = (d + kuriage) + ans; flg = 1; } else { ans = "0" + ans; kuriage = 1; } } } catch(NumberFormatException e) { if(keizoku == 1 && kuriage > 0) { ans = "1" + ans; } ans = str + ans; if(keizoku == 1) flg = 1; } } else { ans = str + ans; } } System.out.println(ans); } } }