zcmu 1524-Problem D: 猜数字

来源:互联网 发布:mac如何装数位板 编辑:程序博客网 时间:2024/06/06 20:50
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;}


0 0
原创粉丝点击