結果

問題 No.104 国道
ユーザー kongarishisyamo
提出日時 2016-03-03 23:16:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 60,900 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 13:58:32
合計ジャッジ時間 1,244 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
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;
	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