結果

問題 No.392 2分木をたどれ
ユーザー Mcpu3Mcpu3
提出日時 2018-12-06 17:27:16
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 28,724 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 02:49:26
合計ジャッジ時間 1,228 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int main(void)
{
	char ans[12], tmp;
	int m, a, top, length, i, j;
	scanf("%d", &m);
	for (i = 0; i < m; ++i) {
		scanf("%d", &a);
		top = 0;
		do {
			if (a % 2) ans[top] = 'L';
			else {
				ans[top] = 'R';
				--a;
			}
			++top;
		} while (a /= 2);
		ans[top] = '\0';
		length = strlen(ans);
		for (j = 0; j < length / 2; ++j) {
			tmp = ans[j];
			ans[j] = ans[length - j - 1];
			ans[length - j - 1] = tmp;
		}
		puts(ans);
	}
	return 0;
}
0