結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
takeya_okino
|
| 提出日時 | 2019-10-02 19:24:48 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,356 bytes |
| コンパイル時間 | 2,525 ms |
| コンパイル使用メモリ | 80,492 KB |
| 実行使用メモリ | 58,816 KB |
| 最終ジャッジ日時 | 2024-10-03 06:02:19 |
| 合計ジャッジ時間 | 4,799 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 2 WA * 1 |
ソースコード
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);
}
}
}
}
takeya_okino