結果

問題 No.501 穴と文字列
ユーザー mori_chibi
提出日時 2017-08-21 10:10:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,169 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 103,060 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-12-14 16:44:18
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace HoleString
{
    class Program
    {
        static void Main(string[] args)
        {
            const char h0 = 'C';
            const char h1 = 'A';
            const char h2 = 'B';
            string[] param = Console.ReadLine().Split(' ');
            int n = int.Parse(param[0]);
            int d = int.Parse(param[1]);
            int num0, num1, num2;
            string r = null;
            if (d < 1)
            {
                num0 = n;
                num1 = 0;
                num2 = 0;
            }
            else if( n < d)
            {
                num0 = 0;
                num1 = 2 * n - d;
                num2 = d - n;
            }
            else
            {
                num0 = n - d;
                num1 = d;
                num2 = 0;
            }
            if (num1 > 0)
            {
                r = r + new string(h1,num1);
            }
            if (num2 > 0)
            {
                r = r + new string(h2, num2);
            }
            if (num0 > 0)
            {
                r = r + new string(h0, num0);
            }
            Console.WriteLine(r);
        }
    }
}
0