Submission #509922
Source Code Expand
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
vector<string> split(const string &str, char delim);
int main(void)
{
// 変数宣言
int n;
int* a;
long long int sum = 0;
// 標準入力
cin >> n;
cin.ignore(); // 改行を飛ばす
a = new int[n];
string tmp;
getline(cin, tmp);
vector<string> tmp2 = split(tmp, ' ');
for (int i = 0; i < n; i++){
a[i] = stoi(tmp2[i]);
}
// 処理
for (int i = 0; i < n; i++){
sum += a[n - i - 1] * pow(2, i);
}
// 標準出力
cout << sum << endl;
return 0;
}
// delim区切りでstring型を取り出す
vector<string> split(const string &str, char delim){
vector<string> res;
size_t current = 0, found;
while ((found = str.find_first_of(delim, current)) != string::npos){
res.push_back(string(str, current, found - current));
current = found + 1;
}
res.push_back(string(str, current, str.size() - current));
return res;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - とても長い数列 |
| User | yonikkusu |
| Language | C++11 (GCC 4.9.2) |
| Score | 100 |
| Code Size | 1020 Byte |
| Status | AC |
| Exec Time | 26 ms |
| Memory | 924 KiB |
Judge Result
| Set Name | Sample | DataSet1 | DataSet2 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 60 / 60 | 40 / 40 | ||||||
| Status |
|
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| DataSet1 | sample-01, sample-02, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt |
| DataSet2 | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 26 ms | 916 KiB |
| 01-02.txt | AC | 24 ms | 792 KiB |
| 01-03.txt | AC | 24 ms | 796 KiB |
| 01-04.txt | AC | 24 ms | 920 KiB |
| 01-05.txt | AC | 24 ms | 796 KiB |
| 01-06.txt | AC | 25 ms | 924 KiB |
| 01-07.txt | AC | 26 ms | 732 KiB |
| 01-08.txt | AC | 26 ms | 732 KiB |
| 02-01.txt | AC | 25 ms | 916 KiB |
| 02-02.txt | AC | 26 ms | 732 KiB |
| 02-03.txt | AC | 26 ms | 912 KiB |
| 02-04.txt | AC | 26 ms | 732 KiB |
| 02-05.txt | AC | 25 ms | 912 KiB |
| 02-06.txt | AC | 26 ms | 728 KiB |
| 02-07.txt | AC | 25 ms | 792 KiB |
| 02-08.txt | AC | 26 ms | 728 KiB |
| sample-01.txt | AC | 25 ms | 916 KiB |
| sample-02.txt | AC | 25 ms | 920 KiB |
| sample-03.txt | AC | 26 ms | 728 KiB |