牛客小白月赛31B

A + B

https://ac.nowcoder.com/acm/contest/10746/B

集资给出题人寄刀片(1/100)

这是一道非常"简单"的题
是思维上的简单
打表加模拟就可以了
需要注意下标

参考代码

#include<bits/stdc++.h>
using namespace std;
int T;
string k[13]={
    "####.##.##.####",
    "..#..#..#..#..#",
    "###..#####..###",
    "###..####..####",
    "#.##.####..#..#",
    "####..###..####",
    "####..####.####",
    "####.##.#..#..#",
    "####.#####.####",
    "####.####..####",
    "....#.###.#....",
};
string a[10];
int find(string op)
{
    for(int i=0;i<=10;i++)
        if(k[i]==op) return i;
    return -1;
}
int n;
int g[105];
void out(int ans)
{
    n=0;
    while(ans){
        g[++n]=ans%10;
        ans/=10;
    }
    for(int i=1;i<=5;i++,printf("\n"))
        for(int j=n;j>=1;j--,j==0?:printf("."))
            for(int q=(i-1)*3;q<i*3;q++)
                cout<<k[g[j]][q];
    cout<<"\n";
}
void work()
{
    int ans=0,tot=0;
    for(int i=1;i<=5;i++)
        cin>>a[i];
    for(int i=0;i<a[1].length();i+=4){
        string op;
        for(int j=1;j<=5;j++){
            op+=a[j][i];op+=a[j][i+1];op+=a[j][i+2];
        }
        int re=find(op);
        if(re==10) {ans+= tot;tot=0;}
        else tot=tot*10+re;
    }
    ans+=tot;
    out(ans);
}
int main()
{
    cin>>T;
    while(T--)
        work();
    return 0;
}
全部评论

相关推荐

2 收藏 评论
分享
牛客网
牛客企业服务