Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <math.h>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int b,n,times=1 ;
- double pop ;
- int a ;
- scanf ("%d",&n) ;
- for ( int i = 0 ; i < n ; i ++ )
- {
- scanf("%d%d",&a,&b) ;
- for ( int j = 2 ; j < 9 ; j ++ )
- {
- double rem = pow(double(a),j) ;
- rem = fmod (rem , 10 ) ;
- if ( rem == a ) break ;
- times ++ ;
- }
- pop = b % times ;
- //printf("%lf\n",rem) ;
- if ( pop == 0 ) pop = times ;
- pop = pow(double(a),pop) ;
- pop = fmod (pop , 10 ) ;
- //times = pop ;
- printf("%lf\n",pop) ;
- }
- //system("PAUSE") ;
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement