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

Abraham Help! [2] // Problem 1014. Product of Digits 2 May 2007 03:40
Hello.

I don't know what is wrong with my solution, maybe someone can help me.
here is my code


#include <stdio.h>

int maxdivisor(unsigned long long n)
{
    for(int i=9;i>1;i--)
        if(n%i==0)
            return i;
    return 1;
}

int main()
{
    unsigned long long n;
    scanf("%Ld",&n);
    if(n==0)
    {
        printf("10");
        return 0;
    }
    if(n<10)
    {
        printf("%Ld",n);
        return 0;
    }
    int dig[100];
    int k=0;
    int d;
    int flag=0;
    while(n>1)
    {
        d=maxdivisor(n);
        if(d==1)
        {
            flag=1;
            n=1;
        }
        else
        {
            dig[k]=d;
            k++;
            n=n/d;
        }
    }
    if(flag==1)
        printf("-1.");
    else
        for(int i=k-1;i>=0;i--)
            printf("%d",dig[i]);
    return 0;
}


Thanks in advance
{AESC USU} Evgeny Kurpilyanskij Re: Help! [1] // Problem 1014. Product of Digits 3 May 2007 22:51
Error here
  printf("-1.");
you must write
  printf("-1");
Abraham Re: Help! // Problem 1014. Product of Digits 22 May 2007 01:53
Altough I corrected it, it is still giving me wrong answer in test 1.