Computer Programming Contest Preparation

ToolBox - Source for: 101/10190/y.cpp



/home/toolbox/public_html/solutions/101/10190/y.cpp
    1 #include <iostream>
    2 using namespace std;
    3 int main()
    4 {
    5     int n{}, m{};
    6     while (cin >> n >> m)
    7         {
    8             int a[100] {n}, k{1};
    9             bool boring{(m == 1 || m == 0 || m > n) ? true : false};
   10             while (!boring && n != 1)
   11                 {
   12                     if (n % m != 0)
   13                         {
   14                             boring = true;
   15                         }
   16                     n /= m;
   17                     a[k++] = n;
   18                 }
   19             if (!boring)
   20                 {
   21                     cout << a[0];
   22                     for (int i{1}; i < k; ++i)
   23                         {
   24                             cout << ' ' << a[i];
   25                         }
   26                     cout << '\n';
   27                 }
   28             else
   29                 {
   30                     cout << "Boring!\n";
   31                 }
   32         }
   33     return 0;
   34 }
   35