e-olymp Problem9 N-digit numbers(打表)

传送门:点我

N-digit numbers

Find the quantity of N-digit numbers, which the sum is equal to their product. Call the least from numbers for given N (N < 10).

Input

The number N is not exceeding 10.

Output

In output file have written 2 numbers: a quantity of numbers and a less number through blank.

Time limit 1 second
Memory limit 64 MiB
Input example #1
1
Output example #1
10 0

题意:给定N,询问N位数中,数的每一位相加等于每一位乘积的,有几个。然后输出第一个这样的数。
比如说如果N等于3,那么123就是一个满足条件的,因为1+2+3==1*2*3。
   如果N等于4,1124是满足条件的,因为1+1+2+4==1*1*2*4。
   因为N<10,我直接暴力把N<10的都打了个表。
代码:
#include <cstdio>
int main()
{
    int n;
    scanf("%d",&n);
    if(n == 1){
        puts("10 0");
    }
    if(n == 2){
        puts("1 22");
    }
    if(n == 3){
        puts("6 123");
    }
    if(n == 4){
        puts("12 1124");
    }
    if(n == 5){
        puts("40 11125");
    }
    if(n == 6){
        puts("30 111126");
    }
    if(n ==7){
        puts("84 1111127");
    }
    if(n == 8){
        puts("224 11111128");
    }
    if(n == 9){
        puts("144 111111129");
    }
}

猜你喜欢

转载自www.cnblogs.com/Esquecer/p/9052311.html