Codeforces Round #247(Div. 2) A. Black Square 水题
来源:互联网 发布:售电软件报价 编辑:程序博客网 时间:2024/06/05 23:43
Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.
In this game, the phone's screen is divided into four vertical strips. Each second, a black square appears on some of the strips. According to the rules of the game, Jury must use this second to touch the corresponding strip to make the square go away. As Jury is both smart and lazy, he counted that he wastes exactly ai calories on touching the i-th strip.
You've got a string s, describing the process of the game and numbers a1, a2, a3, a4. Calculate how many calories Jury needs to destroy all the squares?
The first line contains four space-separated integers a1, a2, a3, a4 (0 ≤ a1, a2, a3, a4 ≤ 104).
The second line contains string s (1 ≤ |s| ≤ 105), where the і-th character of the string equals "1", if on the i-th second of the game the square appears on the first strip, "2", if it appears on the second strip, "3", if it appears on the third strip, "4", if it appears on the fourth strip.
Print a single integer — the total number of calories that Jury wastes.
1 2 3 4123214
13
1 5 3 211221
13
题意:
手机屏幕分成4块,点击每块需要消耗的卡路里给定,然后给定点击列表,求出总的卡路里。
题解:
水题
/*****************PID:431a div2*Auth:Jonariguez******************/#define lson k*2,l,m#define rson k*2+1,m+1,r#define rep(i,s,e) for(i=(s);i<=(e);i++)#define For(j,s,e) For(j=(s);j<(e);j++)#define sc(x) scanf("%d",&x)#define In(x) scanf("%I64d",&x)#define pf(x) printf("%d",x)#define pfn(x) printf("%d\n",(x))#define Pf(x) printf("%I64d",(x))#define Pfn(x) printf("%I64d\n",(x))#define Pc printf(" ")#define PY puts("YES")#define PN puts("NO")#include <stdio.h>#include <string.h>#include <string>#include <math.h>#include <set>#include <map>#include <stack>#include <queue>#include <vector>#include <iostream>#include <algorithm>using namespace std;typedef long long LL;typedef int Ll;Ll quick_pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}const int maxn=100000+10;int a[maxn];char str[maxn];int main(){ int i,j,n,m; for(i=1;i<=4;i++) sc(a[i]); int sum=0; scanf("%s",str+1); n=strlen(str+1); for(i=1;i<=n;i++) sum+=a[str[i]-'0']; printf("%d\n",sum); return 0;}
- Codeforces Round #247(Div. 2) A. Black Square 水题
- Codeforces Round #247 (Div. 2) - A. Black Square
- Codeforces #247 (Div. 2) A. Black Square
- Codeforces Round #247 (Div. 2)a.Black Square,b.Shower Line,c.k-Tree前三题
- Codeforces Round #423 (Div. 2) B. Black Square(思路)
- Codeforces Round #423 (Div. 2) B. Black Square
- Codeforces #423-Div. 2-B. Black Square
- Codeforces Round #423 (Div. 2) B Black Square 黑色正方形 思维题
- codeforces 431A - Black Square
- Codeforces 431A Black Square
- codeforces 431A Black Square
- Codeforces Round #122 (Div. 2) B. Square
- Codeforces 715A & 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))
- Codeforces Round #423 B. Black Square
- Codeforces Round #423 B. Black Square
- Codeforces Round #247 (Div. 2) A B
- Codeforces Round #386 (Div. 2)D. Green and Black Tea
- Codeforces Round #386 (Div. 2) D. Green and Black Tea
- SharedPreference工具类
- VS集成Qt环境搭建
- Eclipse 自动提示设置
- Android Market 链接的生成与分享
- 扣丁学堂笔记第22天多媒体播放
- Codeforces Round #247(Div. 2) A. Black Square 水题
- HADOOP -- 配置Tip 配置hadoop.tmp.dir
- 【Chromium中文文档】Profile架构(看看谷歌家的重构)
- fiddler4使用教程
- ERP开发的一些闲话—之二
- 会话标识未更新问题
- IOS RunLoop浅析 二
- Bzoj1591:[Usaco2008 Dec]Largest Fence 最大的围栏:DP
- ServletRequest接口的主要方法