Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long long FME(int base, int power, int mod){
- if(base==0){
- return 0;
- }
- if(power==0){
- return 1;
- }
- long long res;
- if(power%2==0){
- res = FME(base, power/2, mod);
- res = (res*res)%mod;
- }else{
- res = base%mod;
- res = (res*FME(base, power-1, mod)%mod)%mod;
- }
- return ((res+mod)%mod);
- }
- int main(){
- int tc;
- scanf("%d",&tc);
- while(tc--){
- int a,b;
- scanf("%d %d",&a,&b);
- printf("%lld\n", FME(2,a,1000000007)*FME(3,b,1000000007)%1000000007);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement