ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1014. Product of Digits

Can anyone help me
Posted by Karthick P 27 Jan 2006 20:39
When I run this program its giving correct answer for me but its fails in the Test#1 itself. can anyone point where the wrong has been.
#include<stdio.h>

int main()
{
    long input;
    int output[100];
    int i,j=0;
    scanf("%ld",&input);
        if (input==0)
    {
        printf("10");
        return 1;
    }
    if (input<10)
    {
        printf("%d",input);
        return 1;
    }
    while (input>9)
    {
        for(i=9;i>1;i--)
        {
            if(input%i == 0)
            {
                output[j]=i;
                printf("%d\n",i);
                j++;
                input/=i;
                break;
            }
        }
        if(i==1)
        {
            printf("-1");
            return 1;
        }
    }
    output[j]=input;
    for(i=j;i>=0;i--)
    {
        printf("%d",output[i]);
    }
    return 1;
}
Re: Can anyone help me
Posted by cyanbird 16 Sep 2006 10:40
for n with prime divisor more than 7 it will be loop,for example 11.