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;
}
奔跑吧,兄弟 里有一个猜数游戏 。
提供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;
}
相关文章推荐
- 第16周Problem B: 有相同数字?
- Light oj-1004 - Monkey Banana Problem,数字三角形的变形版~
- Problem E: 用数字造数字(II)
- ZCMU-1151-搭数字2
- [0608] Noip2011 普及组 Problem 1数字反转
- 第16周Problem C: 相同的数字!
- HDOJ1032 The 3n+1 Problem(趣味数字——"角谷猜想"实现)
- 抓起根本(二)(hdu 4554 叛逆的小明 hdu 1002 A + B Problem II,数字的转化(反转),大数的加法......)
- LightOJ 1004 Monkey Banana Problem (线性dp 数字菱形)
- zcmu1519 简单的数字游戏
- ZCMU-训练赛-Problem A: Freckles
- Problem I: C语言实验——打印数字图形
- 11.3 作业 Problem L: 数字统计
- 《ACM程序设计》-Problem-N-输出反转数字和
- 【HDU4474 2012成都现场赛K】【搜索-BFS】Yet Another Multiple Problem 最小的要求字符集的数字倍数 余数哈希BFS
- Problem 2191 完美的数字
- 山科校赛 Problem G: 数字逻辑练习题(进制)
- 第十六周 Problem C:相同的数字
- (Realx 数论1.28)POJ 2282 The Counting Problem(区间统计数字:统计a、b之间各个数字(0~9)出现的次数)
- LightOJ 1004 Monkey Banana Problem (DP 数字三角形)