Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int b,n,times=1 ;
  10. double pop ;
  11. int a ;
  12. scanf ("%d",&n) ;
  13. for ( int i = 0 ; i < n ; i ++ )
  14. {
  15. scanf("%d%d",&a,&b) ;
  16. for ( int j = 2 ; j < 9 ; j ++ )
  17. {
  18. double rem = pow(double(a),j) ;
  19. rem = fmod (rem , 10 ) ;
  20. if ( rem == a ) break ;
  21. times ++ ;
  22. }
  23. pop = b % times ;
  24. //printf("%lf\n",rem) ;
  25. if ( pop == 0 ) pop = times ;
  26. pop = pow(double(a),pop) ;
  27. pop = fmod (pop , 10 ) ;
  28. //times = pop ;
  29. printf("%lf\n",pop) ;
  30. }
  31. //system("PAUSE") ;
  32. return 0 ;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement