結果
| 問題 | 
                            No.104 国道
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Kurichan0806
                         | 
                    
| 提出日時 | 2017-12-05 15:57:55 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 703 bytes | 
| コンパイル時間 | 901 ms | 
| コンパイル使用メモリ | 89,296 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-28 16:39:52 | 
| 合計ジャッジ時間 | 1,697 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;
#define diff(x,y) ((x > y) ? (x - y) : (y - x))
#define us(x) (x > 0) ? x : x * -1
long long int twoten(vector <bool> num);
int main() {
	int ans = 1;
	string str;
	cin >> str;
	vector <bool> num(1,1);
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'L') {
			num.push_back(0);
		}
		else {
			num.push_back(1);
		}
	}
	cout << twoten(num) << endl;
	return 0;
}
long long int twoten(vector <bool> num) {
	long long int ret = 0;
	for (int i = num.size() - 1; i >= 0; i--) {
		ret += num[num.size() - i - 1] * pow(2, i);
	}
	return ret;
}
            
            
            
        
            
Kurichan0806