竖式问题

B.竖式问题
Time Limit: 1000 MSMemory Limit: 32768 K
Total Submit: 1 (1 users)Total Accepted: 1 (1 users)Special Judge: No
Description

竖式问题是:有被乘数xyz和乘数ab(xyzab是被乘数和乘数的各位数字),则xyz乘以ab所得的算式:即竖式中的中间结果和最终结果(即乘积)中的数字均为一给定字符串之中的数字。请找出这样的竖式。被乘数、乘数和结果中各位数字可以重复。

Input
输入一给定字符串作为竖式问题的限定条件。
Output
如果找到满足条件的竖式,输出满足条件的竖式数,如果没有满足条件的竖式,输出none
Sample Input

12

3456

345678

 

 

Sample Output

The number of solutions = 1

none.

The number of solutions = 15

 

#include <stdio.h>
#include <string.h>

int main()
{
    int abc, de, x, y, z, i, ok, count;
    char s[20], buff[100];


     while(~scanf("%s", s))
     {
            count = 0;
            for (abc = 100; abc < 999; abc++)
    {
        for (de = 10; de < 99; de++)
        {
            x = abc * (de % 10);
            y = abc * (de / 10);
            z = abc * de;
            sprintf(buff, "%d%d%d%d%d", abc, de, x, y, z);
            ok = 1;
            for (i = 0; i < strlen(buff); i++)
                if (strchr(s, buff[i]) == NULL)
                    ok = 0;
            if (ok)
            {
                ++count;
               // printf("%5d/nX%4d/n-----/n%5d/n%4d/n-----/n%5d/n", abc, de, x, y, z);
            }
        }
    }
    if(count == 0)
        printf("none.\n");
    else
    printf("The number of solutions = %d\n", count);
     }

    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值