結果

問題 No.539 インクリメント
ユーザー kuuso1kuuso1
提出日時 2017-07-01 16:56:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,899 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 115,732 KB
実行使用メモリ 66,980 KB
最終ジャッジ日時 2024-04-15 07:55:14
合計ジャッジ時間 4,587 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 64 ms
41,816 KB
testcase_02 TLE -
testcase_03 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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 = nmid + new String('0',mid.Length - nmid.Length);
			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));}
}
0