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

yo dawgs here is a problem a big one
Posted by Roman Krylov 3 Aug 2016 23:16
So, i wrote my program for a warn-up to commercial programming, but i have a problem at this problem. It gives me wrong answer at the first test and i need your help, guys from this site. Here's the code:
// Percentofpeople.cpp : Defines the entry point for the console application.
//

// Your task is to find the minimal positive integer number Q so that the product of digits of Q is exactly equal to N.

#include <iostream>
#include <string>


int main()
{
    int number; // a number that we need to get
    std::string answer;
    std::cout << "Enter the number: " << std::endl;
    std::cin >> number;
        for (int i = 9; i >= 2; i--)
        {
            while (number > 1 && number % i == 0) // if we can divide number and before it gets to 1 we'll do the following code:
            {
                answer = std::to_string(i) + answer; // add the number that divides N completely
                number /= i; // divide
            }
        }
        if (number == 1)
            std::cout << answer;
        else
            std::cout << -1;
    std::cin.get();
    std::cin.get();
    return 0;
}

I dunno how it looks but i think you'll understand it. So, where is the problem? The problem is with numbers from 1 to 9 or what?
Re: yo dawgs here is a problem a big one
Posted by Jane Soboleva (SumNU) 4 Aug 2016 00:25
First of all, you should remove or comment out this row
std::cout << "Enter the number: " << std::endl;
The robot doesn't know what this text is supposed to mean, it expects only a numerical answer in the output.
After this, you should be getting WA3.