- import java.util.*;
- class main{
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- while(sc.hasNext()){
- Stack<Long> st = new Stack();
- long n = sc.nextLong();
- long m = sc.nextLong();
- long tmp = 1;
- while(m>1&&tmp<=n){
- st.push(tmp);
- tmp = tmp*m;
- }
- if(!st.empty()&&st.lastElement()==n){
- while(true){
- Long str = st.pop();
- if(str!=1)
- System.out.print(str+" ");
- else {System.out.print(str); break;}
- }
- System.out.println();
- }else System.out.println("Boring!");
- }
- }
- }
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。