The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Far far away from here ,there is a world of peace ,Byteland .But this morning ,Laskar-e-trishul ,a terrorist Organisation has
threatened the people of Byteland declaring that the peaceful land will be bombarded today.The Intelligence of Byteland has intercepted
an encrypted key which is claimed as the key of Bomb.
Programmers were called to Decrypt the key but they were stuck at a problem.
Â
It is required to first evaluate f(A,B) and then key is equal to the no. of pairs (L,M) where
1 such that gcd of L and M is C.
Now Mayer of Byteland is looking for you as his last option.
Note:A^B means A raise to the power B
f(A,B)=K(A^B)
where
K(x)
{
s=0
while(x)
{
s=s+x%10;
x=x/10;
}
if(s>9)
s=K(s);
return s;
}
First Line contains T=No. of test Cases
For each test Case:
Each Line consists of four integers A, B , C, P corresponding to each test case.
For each test case, output the number of desired pairs of (L,M).
1
11
1
2 2 2 6
10
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll