結果

問題 No.104 国道
ユーザー kongarishisyamo
提出日時 2016-03-03 23:19:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 446 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 60,272 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 13:58:51
合計ジャッジ時間 1,229 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cmath>

using namespace std;

#define NMAX 1000000

int main(){

	string S="";
	long long ans;
	long long pos;
	long long bmax,nmax;

	while(cin>>S);

	if(S.size()==0) cout<<"1"<<endl;
	else{
		if(S[0]=='R') ans=3;
		else ans=2;
		for(int i=1;i<S.size();i++){
			bmax=pow(2.0,i)-1;
			nmax=pow(2.0,i+1)-1;
			pos=ans-bmax;
			ans=nmax+1+2*(pos-1);
			if(S[i]=='R') ans++;
		}
		cout<<ans<<endl;
	}

}
0