結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2017-07-01 16:58:19 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,899 bytes |
| コンパイル時間 | 1,004 ms |
| コンパイル使用メモリ | 116,188 KB |
| 実行使用メモリ | 66,980 KB |
| 最終ジャッジ日時 | 2024-10-04 23:36:15 |
| 合計ジャッジ時間 | 4,705 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 TLE * 1 -- * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using BI = System.Numerics.BigInteger;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
for(int i=0;i<N;i++){
var s = S[i];
bool found = false;
int l = -1,r = -1;
int nn = s.Length;
for(int j=nn-1;j>=0;j--){
if(!found){
if(InRange(s[j],'0','9'+1)){
r = j;
l = j;
found = true;
continue;
} else {
continue;
}
}
if(found){
if(InRange(s[j],'0','9'+1)){
l = j;
continue;
} else {
break;
}
}
}
if(!found){
Console.WriteLine(s);
continue;
}
String left = s.Substring(0,l);
String mid = s.Substring(l,(r-l+1));
String right = s.Substring(r+1);
var num = BI.Parse(mid);
num++;
String nmid = num.ToString();
if(nmid.Length < mid.Length) nmid = new String('0',mid.Length - nmid.Length) + nmid;
Console.WriteLine(left + nmid + right);
}
}
bool InRange(int t, int l, int r){
return l <= t && t < r;
}
int N;
String[] S;
public Sol(){
N = ri();
S = new String[N];
for(int i=0;i<N;i++) S[i] = rs();
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
kuuso1