fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. float t,n,k;
  7. cin >> t;
  8. while(t--){
  9. cin >> n >> k;
  10. float x = 1;
  11. if(n < k || k == 1){
  12. cout << n << endl;
  13. }else{
  14. int in = k;
  15. while(n > pow(k,x)){
  16. x++;
  17. }
  18. cout << n << " " << pow(k,x-1) << endl;
  19. }
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5276KB
stdin
2
6492 10
10 1
stdout
6492 1000
10