ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1014. Произведение цифр

yo dawgs here is a problem a big one
Послано Roman Krylov 3 авг 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
Послано Jane Soboleva (SumNU) 4 авг 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.