Black Square (431A - Black Square)
431A - Black Square
Complexity 0(n)
Complexity 0(n)
- #include<iostream>
- using namespace std;
- int main(){
-
- int a,b,c,d;
- string s;
- cin>>a>>b>>c>>d;
- cin>> s;
- int j=0,k=0,l=0,m=0;
-
- for(int i=0;i<s.length();i++){
- if(s[i]=='1') j++;
- if(s[i]=='2') k++;
- if(s[i]=='3') l++;
- if(s[i]=='4') m++;
-
- }
-
- cout<<a*j+b*k+c*l+d*m;
-
- }
Comments
Post a Comment