Codeforces Round #247 (Div. 2)A(构造)

来源:互联网 发布:cctv直播软件下载 编辑:程序博客网 时间:2024/06/05 17:51

题目链接: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 DoubleQ    freopen("in.txt","r",stdin);    #endif    std::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;    }}


0 0
原创粉丝点击