Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

BLAMOEBA — Super Amoeba
Difference between en1 and en2, changed 36 character(s)
[link](http://www.spoj.com/problems/BLAMOEBA/) to spoj problem "blamoeba"↵
i need help to complete this problem. i am stuck since last 2 days. ↵
solution was easy but i am not getting how to use modular inverse to ↵
calculate the final answer. ↵
answer — y/x = (m-1)*(m^n)/(m^n-1)             
(        (where m^n means m to the power m)n). 
how to calculate the gcd of numerator and denominator before using modulo ?        ↵
according to me the answer should be↵

x = (m^n-1)/gcd   ↵
y = (m-1)*(m^n)/gcd↵

help me to do this or correct me if i am doing something wrong 
                  
thanks in advance 

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Survivor 2016-10-26 21:18:19 36 Tiny change: 'the power m). \nhow t' -> 'the power n). \nhow t' (published)
en1 English Survivor 2016-10-26 21:15:14 603 Initial revision (saved to drafts)