今天來解YKL06(UVA10190):Divide, But Not Quite Conquer
n / m 除到最後要是int也要是1
如果不是的話,output Boring!
m不可能大於n
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n,m;
while(cin >> n >> m){
if(m <= 1 || n < m){
cout << "Boring!" << endl;
continue;
}
vector<int> sequence;
sequence.push_back(n);
bool isBoring = false;
while(n > 1){
if(n % m != 0){
isBoring = true;
break;
}
n = n / m;
sequence.push_back(n);
}
if(n!=1){
isBoring = true;
}
if(isBoring){
cout << "Boring!" << endl;
}else{
cout << sequence[0];
for(int i = 1;i < sequence.size();i++){
if(i > 0){
cout << " " << sequence[i];
}
}
cout << endl;
}
}
return 0;
}