本文主要是介绍Codeforces Round #247 (Div. 2)A(构造),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目链接:http://codeforces.com/contest/431/problem/A
解题思路:
构造出来即可。
完整代码:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <complex>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;
typedef long long LL;
const int MOD = int(1e9)+7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1.0); //M_PI;
string s;
int cnt[5];
int main()
{#ifdef DoubleQfreopen("in.txt","r",stdin);#endifstd::ios::sync_with_stdio(false);std::cin.tie(0);while(cin >> cnt[1] >> cnt[2] >> cnt[3] >> cnt[4]){cin >> s;int len = s.length();LL sum = 0;for(int i = 0 ; i < len ; i ++)sum += cnt[s[i] - '0'];cout << sum << endl;}
}
这篇关于Codeforces Round #247 (Div. 2)A(构造)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!