Guest User

UVa 113

a guest
Oct 29th, 2013
195
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***
  2. *
  3. * UVa 113 - Power of Cryptography
  4. *
  5. * Authors: Caio Marcelo
  6. *
  7. * Creation: 18/10/2013
  8. * Last modification:
  9. *
  10. ***/
  11.  
  12. #include <iostream>
  13. #include <iomanip>
  14. #include <cmath>
  15.  
  16. using namespace std;
  17.  
  18. typedef long double Long;
  19.  
  20. Long calcRoot(Long val, Long exp){
  21.     Long i = 1;
  22.     while(i <= val){
  23.         if(val == pow(i, exp)){
  24.             return i;
  25.         }
  26.         i++;
  27.     }
  28.     return 0;
  29. }
  30.  
  31. int main(void){
  32.     Long val, exp;
  33.     while(cin >> exp){
  34.         cin >> val;
  35.         cout << fixed << setprecision(0) << calcRoot(val, exp) << endl;
  36.     }
  37.     return 0;
  38. }
RAW Paste Data