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
Morae Q!
- Program to get dictionary items, use update module and items module.
- Regular expression allowing certain set of characters.
- Compute the Sum of Cosine Series.
- Find the Sum of Sine Series.
- Remove the Vowels from the string.
- Find All Non-Overlapping strings/characters using regular expressions .
- Check whether the given string is Panagram or not.
- Replacing strings using Regular Expression Regex.
- Check whether the given number is Strong number or not.
- Find the numbers divisible by a input numbers within the given range.
- Change the behaviour of the Regular Expression using flags.
- Find the exponentiation of a number.
- Find all prime numbers in a range using Sieve of Eratosthenes.
- Convert decimal equivalent into binary, hexadecimal and octal.
- Compute the area of a farmers field in feet.
- Compute time from number of days/hours to seconds.
- Precompiled patterns using Regular Expressions .
- Compute the price of the cake on the nth day.
- Compute the number of possible non-increasing arrays.
- Find the type of spinach using the calorie value.