蒟蒻的第一篇题解,求过。
题目大意
就是给你每个 LED 灯的状态,让你判断为哪个数字,如不是数字,对应的位置输出*号。
思路
打表。
用一个 string 的二维数组存储 至 的字符形态,然后遍历输入的每一个字符串所代表的对应的 LED 灯,判断为哪一个数字,然后存到 数组里,就搞定了。
AC code
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
string num,ans[maxn];
string nn[10] = {
"1110111",
"0000011",
"0111110",
"0011111",
"1001011",
"1011101",
"1111101",
"0010011",
"1111111",
"1011111"
};
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>num;
vector<int>c;
for(int d=0;d<10;d++){
bool x=true;
for(int j=0;j<7;j++){
if(num[j]=='G'||num[j]=='g'){
int q=nn[d][j]-'0';
int w=(num[j]=='G')?1:0;
if(q!=w){
x=false;
break;
}
}
}
if(x){
c.push_back(d);
}
}
if(c.size()==1){
ans[i-1]='0'+c[0];
}else{
ans[i-1]='*';
}
}
for(int i=0;i<n;i++)cout<<ans[i];
return 0;
}