Menu Close

Compute the price of the cake on the nth day

Fahad’s Birthday is a week ahead. Arav and his friends are planning to give him a birthday party. For that Arav’s friends want him to buy the cake. 

He needs to pay ‘x’ amount of money to buy the Blackforest cake on the first day.  After each day has passed, the Blackforest cake becomes ‘x’ times the price that it was on the previous day. 

For buying the Blackforest cake Arav has to collect money from all the friends and for that,he need ‘y’ days and after ‘y’ days he will go and buy the Blackforest cake.

Arav seeks your help in calculating the price of Blackforest cake on the yth day.
Take the price as modulo 10^9 + 7 as the price can be very large.

Input:
The first line contains an integer T, the number of testcases. It's followed by T lines.
Each Testcase will contain two integers X & Y separated by a space.

Output:
Print the output T lines, each corresponding to the answer of the testcase.

#include <stdio.h>
#define mod 1000000007
int main()
{int t;
scanf("%d",&t);
while(t--){
 long long unsigned int x,y;
 scanf("%llu %llu",&x,&y);
 int a=x;
 int i;
 for(i=0;i<y-1;i++){
 x=(a*x)%mod;
 }
 printf("%llu\n",x);
}
return 0;
}


INPUT_1:
2
14  3
9  6

OUTPUT:
2744
531441


INPUT_2:
4
17  5
11  9
5  2
9  7

OUTPUT:
1419857
357947677
25
4782969


ILLUSTRATION OF THE OUTPUT, WHEN EXECUTING THE CODE

Executed using gcc linux

Morae Q!

  1. Program to get dictionary items, use update module and items module.
  2. Regular expression allowing certain set of characters.
  3. Compute the Sum of Cosine Series.
  4. Find the Sum of Sine Series.
  5. Remove the Vowels from the string.
  6. Find All Non-Overlapping strings/characters using regular expressions .
  7. Check whether the given string is Panagram or not.
  8. Replacing strings using Regular Expression Regex.
  9. Check whether the given number is Strong number or not.
  10. Find the numbers divisible by a input numbers within the given range.
  11. Change the behaviour of the Regular Expression using flags.
  12. Find the exponentiation of a number.
  13. Find all prime numbers in a range using Sieve of Eratosthenes.
  14. Convert decimal equivalent into binary, hexadecimal and octal.
  15. Compute the area of a farmers field in feet.
  16. Compute time from number of days/hours to seconds.
  17. Precompiled patterns using Regular Expressions .
  18. Compute the price of the cake on the nth day.
  19. Compute the number of possible non-increasing arrays.
  20. Find the type of spinach using the calorie value.