Re: Competitive Programming Life Starting from Zero Chapter 1.3 "Sedo Tea"

Learning report

ABC154 I was full of participation, but I didn't have this week orz So I will solve the past questions this time as well !!

Last time I solved the B problem, and the next one was the C problem, but it was unexpectedly difficult, and for the past 5 days I was trying to solve the problems up to A-C.

Along the way, I noticed that the problem was colored according to the difficulty level (slow). If you look at the color, the problem that I was happy to receive AC is gray ()

In other words, my current ability is gray ...

Let's solve the tea problem !!!!

Challenge tea

So, here is the problem to be solved this time image.png

This is brown ... my fingers don't move. Let's take a look at an output example for the time being. image.png

I see !! Once you replace the number in this probability formula with an appropriate variable (i for the roll, j for the number of times you swing the coin),

1/i*(0.5**j)

If you repeat this formula in a sentence and add it up, you will be asked for an answer !!

N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  j = 0
  point = i
  while point < K:
    point *= 2
    j += 1
  ans += (1/N)*(0.5**j)
print(ans)

You got AC with this !!

I wrote it briefly in the article, but it took me an hour to solve it. I have to think more and write the code ... Also, it seems that you need to know various things such as binary search and dynamic programming in order to solve problems of higher difficulty, so I will also learn that. It looks like a flat tire ()

Thank you for reading. The next update is likely to be after ABC154, but please read it again if you like.

Recommended Posts

Re: Competitive Programming Life Starting from Zero Chapter 1.3 "Sedo Tea"
Re: Competitive Programming Life Starting from Zero Chapter 1.2 "Python of Tears"
Re: Competitive programming life starting from zero Chapter 1 1 "Only C ++ can be used"
Re: Competitive programming life starting from zero In order for beginners to get as high a performance as possible ~ ABC154 ~ 156 with impressions ~
ChIP-seq analysis starting from zero
[For beginners] Re: Genetic algorithm starting from zero [Artificial intelligence]
Re: Life in Heroku starting from scratch with Flask ~ PhantomJS to Heroku ~
Deep Learning / Deep Learning from Zero 2 Chapter 4 Memo
Deep Learning / Deep Learning from Zero Chapter 3 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 5 Memo
Code wars kata starting from zero
Deep Learning / Deep Learning from Zero 2 Chapter 7 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 8 Memo
Deep Learning / Deep Learning from Zero Chapter 5 Memo
Deep Learning / Deep Learning from Zero Chapter 4 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 3 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 6 Memo
Re: Life in Heroku starting from scratch with Flask ~ Selenium & PhantomJS & Beautifulsoup ~
Re: Heroku life begin with Flask from zero - Environment and Hello world -
"Python AI programming" starting from 0 for windows