[uva1588]Kickdown

注意事项

1.一定要注意分析的方法,不要陷入列举有什么符合,而尽量先考虑什么不行,排除就好。
2.三个错误点
    1.上下不一定是上长下短。
    2.可以在板子里面也可以有一部分到外面
    3.可以向左伸,也可以向右伸。

心得体会

一定要反向思维,看看什么不行。直接列举实在太难想全。


渣渣代码

#include <stdio.h>
#include <string.h>
char topLineT[1000], bottomLineT[1000];
void check(void);
int main(void)
{
    while (gets(bottomLineT))
    {
        gets(topLineT);
        check();
    }
    return 0;
}
void check(void)
{
    int lenTop = strlen(topLineT), lenBottom = strlen(bottomLineT);
    char topLine[1000], bottomLine[1000];
    if (lenTop > lenBottom)
    {
        strcpy(topLine, bottomLineT);
        strcpy(bottomLine, topLineT);
        int temp = lenTop;
        lenTop = lenBottom;
        lenBottom = temp;
    }
    else
    {
        strcpy(topLine, topLineT);
        strcpy(bottomLine, bottomLineT);
    }

    //不伸出去
    for (int count1 = 0; count1 <= lenBottom - lenTop; count1++)
    {
        for (int count2 = 0; count2 <= lenTop; count2++)
        {
            if (bottomLine[count1 + count2] + topLine[count2] >= 2 * '2')
            {
                break;
            }
            if (count2 == lenTop)
            {
                printf("%d\n", lenBottom);
                return;
            }
        }
    }
    //伸出去
    for (int count1 = 1; count1 < lenTop; count1++)
    {
        for (int count2 = 0; count2 + count1 <= lenTop; count2++)
        {
            if (topLine[count1 + count2] + bottomLine[count2] >= 2 * '2')
            {
                break;
            }
            if (count2 + count1 == lenTop)
            {
                printf("%d\n", count1 + lenBottom);
                return;
            }
        }
        for (int count2 = 0; count1 + count2 <= lenTop; count2++)
        {
            if (topLine[lenTop - count1 - count2] + bottomLine[lenBottom - count2] >= 2 * '2')
            {
                break;
            }
            if (count1 + count2 == lenTop)
            {
                printf("%d\n", count1 + lenBottom);
                return;
            }
        }
    }
    printf("%d\n", lenBottom + lenTop);
    return;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值