題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1131
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
| #include <iostream> #include <vector>
using namespace std;
int main(){ int num; int div; while(cin >> num >> div){ if(num <= 1 || div <= 1){ cout << "Boring!\n"; continue; } vector<int> ans; ans.push_back(num); bool boring = false;
while(num > 1){ if(num % div == 0){ num /= div; ans.push_back(num); } else{ boring = true; break; } } if(boring) cout << "Boring!\n"; else{ bool first = true; for(int n : ans){ if(first) first = false; else cout << ' '; cout << n; } cout << '\n'; } } }
|