結果
| 問題 | No.539 インクリメント | 
| コンテスト | |
| ユーザー |  takeya_okino | 
| 提出日時 | 2017-09-23 19:21:56 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,426 bytes | 
| コンパイル時間 | 2,518 ms | 
| コンパイル使用メモリ | 79,732 KB | 
| 実行使用メモリ | 75,424 KB | 
| 最終ジャッジ日時 | 2024-11-14 04:22:02 | 
| 合計ジャッジ時間 | 12,430 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | TLE * 3 | 
ソースコード
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.nextLine();
      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;
        }
        if(j == 0 && flg == 0 && kuriage == 1) {
          ans = "1" + ans;
        }
      }
      System.out.println(ans);
    }
  }
}
            
            
            
        