結果

問題 No.104 国道
ユーザー nanophoto12nanophoto12
提出日時 2015-12-13 22:42:10
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 670 bytes
コンパイル時間 1,859 ms
コンパイル使用メモリ 102,232 KB
実行使用メモリ 22,572 KB
最終ジャッジ日時 2023-10-13 15:02:48
合計ジャッジ時間 3,877 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
20,468 KB
testcase_01 AC 46 ms
20,468 KB
testcase_02 AC 47 ms
20,416 KB
testcase_03 AC 44 ms
22,484 KB
testcase_04 AC 47 ms
20,556 KB
testcase_05 AC 46 ms
22,528 KB
testcase_06 AC 48 ms
20,432 KB
testcase_07 AC 47 ms
18,360 KB
testcase_08 AC 47 ms
20,556 KB
testcase_09 AC 49 ms
22,508 KB
testcase_10 AC 52 ms
22,544 KB
testcase_11 AC 47 ms
18,428 KB
testcase_12 AC 49 ms
22,460 KB
testcase_13 AC 47 ms
20,424 KB
testcase_14 AC 48 ms
18,428 KB
testcase_15 AC 48 ms
20,472 KB
testcase_16 AC 49 ms
22,472 KB
testcase_17 AC 49 ms
20,432 KB
testcase_18 AC 48 ms
22,572 KB
testcase_19 AC 48 ms
20,640 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Generic;
using System.Linq;

namespace No104
{
	class MainClass
	{
		private static long LeftPosition(int length)
		{
			long index = 1;
			for (int i = 0; i < length; i++) {
				index *= 2;
			}
			return index;
		}

		public static void Main (string[] args)
		{			
			var s = Console.ReadLine ();
			if (s.Length == 0) {
				Console.WriteLine ("1");
				return;
			}
			var leftPosition = LeftPosition (s.Length);
			var length = leftPosition / 2L;
			for (int i = 0; i < s.Length; i++) {
				if (s [i] == 'R') {
					leftPosition += length;
				} 
				length /= 2L;
			}
			Console.WriteLine (leftPosition.ToString());
		}
	}
}
0