s_mahmud's blog

By s_mahmud, history, 7 days ago, In English

Given 4 numbers A,B,C and D. If A ^ B > C ^ D print "YES" otherwise, print "NO".

Input : Only one line containing 4 numbers A,B,C and D (1 ≤ A,C ≤ 10^7 ) , (1 ≤ B,D ≤ 10^12 )

Output : Print "YES" or "NO" according to the problem above.

Problem Link — Here

I think I have to mod this. But what's the real approach?

TIA.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Take log on both sides. Check for b*log(a) > d*log(c).Submission link : 92842700

  • »
    »
    7 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Didn't get you, can you please explain, if you don't mind

    • »
      »
      »
      7 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Generally, Log(a^b) is b*Log(a). The log of a larger number will be greater than the log of a smaller number. Taking Logarithm allows comparing larger numbers.

»
7 days ago, # |
  Vote: I like it 0 Vote: I do not like it

We know that log(a^b)= b*log(a) So, if we apply log on both sides it will be:- log(a^b)>log(c^d) --> b*log(a)>c*log(d) Then you apply necessary modular arithmetic to solve the problem :)