結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-07-11 18:29:21 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,631 bytes |
| コンパイル時間 | 2,311 ms |
| コンパイル使用メモリ | 115,120 KB |
| 実行使用メモリ | 47,664 KB |
| 最終ジャッジ日時 | 2024-10-07 15:03:41 |
| 合計ジャッジ時間 | 3,657 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 1 RE * 2 |
コンパイルメッセージ
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.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
class Program
{
static void Main()
{
new Magatro().Solve();
}
}
class Magatro
{
private int T;
private string Func(string s)
{
int? left = null, right = null;
for (int i = s.Length - 1; i >= 0; i--)
{
if ('0' <= s[i] && s[i] <= '9' && !right.HasValue)
{
right = i;
}
else if(!('0' <= s[i] && s[i] <= '9')&&right.HasValue)
{
left = i + 1;
break;
}
}
if (right.HasValue && !left.HasValue)
{
left = 0;
}
if (left == null) return s;
string a = s.Remove(left.Value);
string c = s.Substring(right.Value + 1);
string bb = s.Substring(left.Value, right.Value - left.Value + 1);
string b;
if (s[left.Value] == '0')
{
b = (int.Parse(bb) + 1).ToString().PadLeft(right.Value - left.Value + 1,'0');
}
else
{
b = (int.Parse(bb) + 1).ToString();
}
return a + b + c;
}
private void Scan()
{
T = int.Parse(Console.ReadLine());
}
public void Solve()
{
Scan();
var sb = new StringBuilder();
for (int i = 0; i < T; i++)
{
sb.AppendLine(Func(Console.ReadLine()));
}
Console.WriteLine(sb.ToString());
}
}
mban