您的位置:首页 > 其它

A - Product of Digits URAL - 1014(数位操作)

2017-12-11 17:17 225 查看
Your task is to find the minimal positive integer number Q so that the product of digits of Q is exactly equal to N.


Input

The input contains the single integer number N (0 ≤ N ≤ 10 9).

Output

Your program should print to the output the only number Q. If such a number does not exist print −1.

Example

input

10


output

25


题意:输出的数的两个数位相乘刚好等于输入 的数,有两个坑点,一个是输入0的时候输出10,还有一个就是输出-1的情况是除到不能再除的时候那个数必须小于10.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int i,n,a[1000];
int count;
while(~scanf("%d",&n))
{
if(n==0)
{
printf("10\n");
}
else if(n<10)
printf("%d\n",n);
else
{
count = 0;
for(i=9;i>=2;i--)
{
while(n%i==0&&n!=1)
{
a[count++] = i;
n/=i;
}
}
if(n > 10)
printf("-1\n");
else
{
for(i=count-1;i>=0;i--)
{
printf("%d",a[i]);
}
printf("\n");
}
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: