heysem's blog

By heysem, history, 4 years ago, In English

Hello Codeforces,

I've been practicing C++ to improve myself but I kinda stuck with a question. I was hoping you could help.

I met the sqrt(); function and I wonder if I could make it up to 3rd or 4th and even more degrees of root? How can I do that?

Sorry for the bad English btw I am a new learner and I am trying hard to fix my mistakes so if you have any corrections about the usage of language pls inform me.

Thanks already!

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it +4 Vote: I do not like it

One of the methods is to use the pow() function. To calculate the Kth root of N, use pow(N, 1/K). (Remember to use double)

»
4 years ago, # |
  Vote: I like it +10 Vote: I do not like it

You can apply binary search, find the largest x such that x^k <= n.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    What's binary search? I have no idea what it is.