Gym - 101480A_ASCII Addition

Posted luoxiaoyi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gym - 101480A_ASCII Addition相关的知识,希望对你有一定的参考价值。

题目链接

技术分享图片

技术分享图片

题解:普通的a+b才怪问题,需要绘制出来,方法有点麻烦。

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <stack>
#include <stack>

using namespace std;

char s[10][200],s2[10][200];
char num[7][11][6] = {
"xxxxx","....x","xxxxx","xxxxx","x...x","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx",".....",
"x...x","....x","....x","....x","x...x","x....","x....","....x","x...x","x...x","..x..",
"x...x","....x","....x","....x","x...x","x....","x....","....x","x...x","x...x","..x..",
"x...x","....x","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx","....x","xxxxx","xxxxx","xxxxx",
"x...x","....x","x....","....x","....x","....x","x...x","....x","x...x","....x","..x..",
"x...x","....x","x....","....x","....x","....x","x...x","....x","x...x","....x","..x..",
"xxxxx","....x","xxxxx","xxxxx","....x","xxxxx","xxxxx","....x","xxxxx","xxxxx","....."};
int f[15];

void cmp(int l,int r,int x)
{
    int i,j;
    for(i=0;i<=10;i++)
    {
        if(!f[i])
            continue;
        for(j=0;j<5;j++)
        {
            if(s[x][l+j]!=num[x][i][j])
                break;
        }
        if(j!=5)
            f[i] = 0;
    }
}

int read(int l,int r)
{
    int i;
    for(i=0;i<=10;i++)
        f[i] = 1;
    for(i=0;i<7;i++)
        cmp(l,r,i);
    for(i=0;i<=10;i++)
    {
        if(f[i])
            return i;
    }
    return -1;
}

long long c;

void show(long long x,int a)
{
    if(x>=10)
        show(x/10,a);
    if(x!=c)
        printf("%s.",num[a][x%10]);
    else
        printf("%s
",num[a][x%10]);
}

int main()
{
    int i;
    long long a,b,n,sum;
    for(i=0;i<7;i++)
        scanf("%s",s[i]);
    n = strlen(s[0]);
    a = b = 0;
    sum = 0;
    for(i=0;i<n;i+=6)
    {
        c = read(i,i+5);
        if(c==10)
        {
            a = sum;
            sum = 0;
        }
        else
        {
            sum *= 10;
            sum += c;
        }
    }
    b = sum;
    c = a + b;
    for(i=0;i<7;i++)
        show(c,i);
    return 0;
}

以上是关于Gym - 101480A_ASCII Addition的主要内容,如果未能解决你的问题,请参考以下文章

Gym 101480I Ice Igloos(思维乱搞)题解

Gym101522A Gym101522C Gym101522D

Gym Gym 101147G 第二类斯特林数

OpenAI Gym 入门与提高 Gym环境构建与最简单的RL agent

强化学习 平台 openAI 的 gym 安装 (Ubuntu环境下如何安装Python的gym模块)

openai/gym 中各种环境(Env)的参数解释