結果

問題 No.392 2分木をたどれ
ユーザー noriocnorioc
提出日時 2016-08-12 02:33:19
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 1,512 ms
コンパイル使用メモリ 67,900 KB
実行使用メモリ 23,848 KB
最終ジャッジ日時 2023-08-07 11:56:23
合計ジャッジ時間 1,892 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
21,500 KB
testcase_01 AC 69 ms
23,848 KB
testcase_02 AC 72 ms
23,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }
    static void Display<T> (IEnumerable<T> xs) { Console.WriteLine(string.Join(" ", xs)); }

    static string Calc(int x) {
        var ans = new List<string>();

        while (x > 0) {
            if (x % 2 == 0) {
                ans.Add("R");
            }
            else {
                ans.Add("L");
            }
            x = (x - 1) / 2;
        }
        return string.Join("", ans.Reverse<>());
    }

    static void Main() {
        int n = ReadInt();
        for (int i = 0; i < n; i++) {
            int x = ReadInt();
            Console.WriteLine(Calc(x));
        }
    }
}
0