您的位置:首页 > 其它

zcmu 1524-Problem D: 猜数字

2016-08-13 20:48 127 查看
Description

奔跑吧,兄弟 里有一个猜数游戏 。

提供X个信息:

0=1

1=0

2=0

3=0

4=0

5=0

6=1

7=0

8=2







38269=4

17522=0

请问对于整数N ,求出N对应的数字

Input

第一行输入一个T(T<=100),表示有T组数据。

接下来每行输入一个整数N (0<=N<10^1000)

Output

输出N对应的数字。

Sample Input

4

38269

8888

6668

17522

Sample Output

4

8

5
0

找规律

code:

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<math.h>
#include<string.h>
#include<stdlib.h>

using namespace std;
typedef long long ll;

int main(){
// freopen("input.txt","r",stdin);
int t;
int a[10]={1,0,0,0,0,0,1,0,2,1};
cin>>t;
while(t--){
string s;
int num=0;
cin>>s;
for(int i=0;i<s.length();i++){
int m=s[i]-'0';
num+=a[m];
}
cout<<num<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  acm zcmu 1524-Problem D