-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa10190.cpp
More file actions
47 lines (46 loc) · 790 Bytes
/
UVa10190.cpp
File metadata and controls
47 lines (46 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// shortcuts for "common" data types in contests
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
int main()
{
int n, m;
while (scanf("%d %d", &n, &m) != EOF)
{
int ans = n;
bool boring = m < 2 || ans % m != 0 || m > n;
vi seq;
seq.push_back(n);
while (ans != 1)
{
if (m < 2 || ans % m != 0 || m > n)
{
boring = true;
break;
}
ans /= m;
seq.push_back(ans);
}
if (boring)
printf("Boring!\n");
else
{
for (int i = 0; i < (int) seq.size(); i++)
{
if (i > 0)
printf(" ");
printf("%d", seq.at(i));
}
printf("\n");
}
}
return 0;
}