1 条题解

  • 0
    @ 2023-11-14 20:04:56

    wanangiegie亲情奉献题解一篇

    #include<stdio.h>
    #include<string.h>
    
    char a[100], b[100], c[100];
    int getnum(int n, char s[])
    {
        int sum = 0;
        for(int i = 0; i < strlen(s); i++)
        {
            int p = s[i];
            int t;
            if(p >= '0' && p <= '9')
                t = p - '0';
            else
                t = p - 'A' + 10;
            if(t >= n)
            {
                return -1e8;
            }
            sum = sum * n + t;
        }
        return sum;
    }
    int main()
    {
        int t, x, y, z;
        scanf("%d", &t);
        while(t--)
        {
            scanf("%s", a);
            scanf("%s", b);
            scanf("%s", c);
            if(a[0] == '0' || b[0] == '0')
            {
                printf("16\n");
            }
            else
            {
                for(int i = 2; i <= 16; i++)
                {
                    x = getnum(i, a);
                    y = getnum(i, b);
                    z = getnum(i, c);
                    if(x + y == z)
                    {
                        printf("%d\n", i);
                        break;
                    }
                }
            }
        }
    }
    

    信息

    ID
    931
    时间
    2000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    103
    已通过
    12
    上传者