You've studied how to count the number of 0 digits at the end of $$$n!$$$. But that was for numbers written in decimal. Real computer scientists think in binary! How many 0 digits are at the end of $$$n!$$$ when the result is expressed in binary?
The only line of input contains a single integer $$$n$$$ $$$(1 \leq n \leq 10^6).$$$ (Note that this integer is written in decimal, not binary.)
Print the number of 0 digits at the end of $$$n!$$$, when this integer is written in binary.
1
0
8
7
1000000
999993
Factorials grow very quickly. Any solution that requires computing $$$n!$$$ as a first step will probably not work here!
Michael is the manager of a massive 24-hour supermarket. Using cameras at the doors, he has recorded the entry and exit times for $$$N$$$ customers.
He wants to calculate the following statistic: among $$$M$$$ minutes of the day, what is the median number of customers present in the store?
The first line contains two integers, $$$N$$$ and $$$M$$$. Each of the following $$$N$$$ lines contains two integers, $$$t_{first}$$$ and $$$t_{last}$$$, representing the first and last minutes a customer spends in the store. The customer enters at the beginning of $$$t_{first}$$$ and leaves at the end of $$$t_{last}$$$.
Print the median number of customers present in the store. Your answer will be judged correct if it matches the judge solution with absolute or relative error at most $$$10^{-6}$$$.
10 101 51 82 32 93 53 64 106 87 97 10
5.5
8 91 51 82 32 93 53 66 87 9
4
In the first input, the number of customers per minute is $$$[2, 4, 6, 6, 6, 5, 6, 6, 4, 2]$$$. The median of this list is $$$5.5$$$.
How often has this happened to you: you are trying to plan a group movie night, so you ask your friends if they'd like to join. "Well, I'm really busy with CS429 homework. But maybe if Cooper and Ava also come..."
You are given a list of friends, and for each friend, their dependencies. Each friend will attend the movie night if and only if all of their dependencies also attend.
You also have a list of best friends you definitely want there.
What is the minimum number of people you need to invite to the movie night so that your best friends attend?
The first line of input contains a single integer $$$n$$$ $$$(1 \leq n \leq 100)$$$, the number of potential friends you could invite to the movie night. The next $$$n+1$$$ lines describe you and your friends. Each line begins with a string of between $$$2$$$ and $$$10$$$ ASCII uppercase and lowercase letters; this string is the name of one friend. Then follows an integer $$$k$$$ ($$$0 \leq k \leq n$$$), the number of people on that friend's list of dependencies. The line ends with $$$k$$$ space-separated strings, the names of the friends on the dependency list.
One row starts with the name You. The dependencies of You are the friends you want to be sure attend the movie night.
No two rows start with the same string. Every string in every dependency list is the name of somebody with a row in the input. Nobody is on their own dependency list, and the same name doesn't appear twice on any one dependency list.
Print the minimum number of friends you need to invite (not including You) to guarantee that the people on You's dependency list show up.
4Brad 2 Cooper AvaCooper 0Ava 2 Brad YouAnnie 2 Brad CooperYou 1 Brad
3
3Yingying 2 You LuisLuis 2 Yingying MingyuYou 0Mingyu 1 Luis
0
Given a cubic polynomial $$$$$$f(x) = x^3 + a x + b$$$$$$ it can be shown that if $$$a$$$ and $$$b$$$ are non-negative, then $$$f(x)$$$ has exactly one real root $$$f(r) = 0$$$. Find $$$r$$$.
The only line of input contains two real numbers $$$a$$$ and $$$b$$$ $$$(0 \leq a,b \leq 10^9)$$$.
Find the real root $$$r$$$ with $$$f(r) = 0$$$. It can be proved that exactly one such $$$r$$$ exists. Your answer will be judged correct if it matches the judge solution with absolute or relative error at most $$$10^{-6}$$$.
0 0
2.98023223876953125e-08
3.14 1000000000.0
-999.998953342059394344687461853
6.0 7.0
-0.9999999701976776123046875
Hint 1: be sure to print your answer with lots of digits after the decimal point to make sure that it is within the absolute or relative error bounds.
Hint 2: be sure to use double-precision floating point numbers (not 32-bit floats).
Magikarp likes to explore Karpville, but sometimes his phone runs out of battery when he is far from home. Karpville is made up of $$$n$$$ intersections and $$$m$$$ one-way streets, the $$$j$$$-th of which goes from intersection $$$u_j$$$ to intersection $$$v_j$$$ and takes $$$w_j$$$ minutes to drive.
Magikarp wonders, if he were to start at intersection $$$i$$$, what is the shortest amount of time (in minutes) it takes to reach his apartment, located at intersection $$$n$$$, if he is only allowed to drive? Help Magikarp answer this question for all intersections.
If Magikarp cannot drive back from some intersection, print $$$-1$$$ for that answer. Note that there can be multiple roads between the same pair of intersections.
Psst... the answers can exceed the size of a 32-bit integer!
The first line of input contains $$$n$$$ and $$$m$$$ $$$(1\le n,m\le 2\cdot 10^5)$$$ — the number of intersections and the number of one-way streets, respectively.
The $$$j$$$-th of the next $$$m$$$ lines contains 3 integers $$$u_j$$$, $$$v_j$$$, and $$$w_j$$$ $$$(1\le u_j,v_j\le n, u_j\neq v_j, 0\le w_j\le 10^9)$$$ — the starting intersection, ending intersection, and distance (in minutes) for the $$$j$$$-th one-way road.
Output $$$n$$$ lines, each containing a single integer. The $$$i$$$-th number should represent the shortest time (in minutes) it will take Magikarp to drive back to his apartment if he starts at intersection $$$i$$$, or $$$-1$$$ if this is impossible.
3 31 2 12 3 21 3 5
3 2 0
6 91 2 12 1 05 2 03 2 44 5 33 4 23 5 75 6 25 6 0
-1 -1 5 3 0 0