You've planted a new tree in your backyard. You're curious about how the diameter of the tree trunk changes over time. Obviously, the diameter never decreases—the tree only grows thicker over time—but during the spring the diameter increases most quickly, and during winter it barely increases at all.
From the data you've collected, you fit the following function for the diameter $$$d$$$ of the tree, given the time $$$t$$$ since you've planted it:
$$$d(t) = t + \sin t$$$.
Where the $$$\sin$$$ function takes in radians.
Now you want to know: given a target diameter $$$d_{\textrm{tar}}$$$, how long will it take for the tree to reach that diameter?
The only line of input contains a single real number $$$d_{\textrm{tar}}$$$: the target diameter of the trunk of your tree. This target diameter satisfies the bounds $$$0 \leq d_{\textrm{tar}} \leq 10^6.$$$
Print a single real number $$$t$$$: the time at which $$$d(t) = d_{\textrm{tar}}$$$.
To be judged correct, your answer must match the judge solution with relative or absolute error at most $$$10^{-4}$$$.
3.32
4.183233892618
1000000
1000000.178303
0
0
Hint: to make sure that your answer satisfies the above tolerance bound, be sure to print lots of digits (at least 5) after the decimal point!
You are playing around with a construction set of rigid blocks. You would like to stack the blocks to build a tower that is $$$H$$$ inches high. The construction set consists of many copies of blocks of different colors; blocks with the same color are identical and, in particular, all have the same height.
What is the least number of blocks you need to stack on top of each other in order to build a tower of height exactly $$$H$$$ inches?
You may assume that the construction set has infinitely many copies of each color block.
The first line of input consists of two space-separated integers $$$H$$$ and $$$n$$$: the height of the tower that you want to build, in inches ($$$0 \lt H \leq 10^5$$$) and the number of different colors of blocks in the construction set ($$$1 \leq n \leq 10$$$).
The next $$$n$$$ lines each contain an integer $$$h$$$ $$$(1 \leq h \leq 100)$$$: the height, in inches, of the blocks of each of the $$$n$$$ colors.
If it impossible to build a tower of height $$$H$$$ inches, print $$$-1$$$. Otherwise, print the minimum number of blocks you need to stack on top of each other to build the tower.
20 31151
4
99999 624681012
-1
You are standing in line for the buffet at a recruiting event. The buffet consists of a sequence of food items, where each item has a different desirability. You can choose to add each item to your plate, or to skip it.
You want to maximize the total desirability of the food on your plate; however, to avoid being selfish, you don't want to take two consecutive items from the buffet. In other words, if you choose to add item $$$i$$$ to your plate, then you must choose to skip item $$$i+1$$$.
Given this constraint, what is the maximum desirability of the food on your plate, if you choose to add items optimally?
The first line of input contains a single integer $$$n$$$ $$$(1 \leq n \leq 10\,000)$$$, the number of food items in the buffet.
The next line consists of $$$n$$$ space-separated integers $$$d_i$$$ $$$(0 \leq d_i \leq 1\,000)$$$, the desirability of the $$$i$$$th food item in the buffet.
Print the maximum possible total desirability of the food on your plate, if you choose to add items optimally without taking two consecutive items from the buffet.
53 8 10 2 0
13
70 9 10 2 0 0 0
11
142
42
A game of Mini Minesweeper is played on an $$$8 \times 8$$$ grid. At the start of the game, each square of the grid is either hidden or revealed. Exactly $$$M$$$ of the hidden squares contain mines; the others are empty. Written on each revealed square is a number between $$$0$$$ and $$$8$$$ inclusive: the number of hidden cells adjacent to the square (in the four orthogonal and four diagonal directions) that contain a mine.
You are helping your friend debug their Mini Minesweeper implementation, and so you need to write a checker for the initial board state. The checker should analyze the board and decide: is there a possible placement of the $$$M$$$ mines in hidden squares so that all of the numbers written on the revealed squares correctly identify the number of adjacent mines?
The first line of input contains a positive integer $$$M \leq 64$$$: the number of mines distributed throughout the hidden squares of the game board.
The following eight lines contain eight characters each and describe the initial game board. Each character is either #, indicating a hidden square, or a digit 0 through 8, indicating a revealed square with that digit written on it.
Print VALID if there exists some placement of $$$M$$$ mines in the hidden squares so that every number written on a revealed square correctly identifies the number of neighboring mines. Print INVALID otherwise.
27#######34##54#######3###4#7544#22####21114##3#00#3#42#11##2#11#1
VALID
200000000000000000000000000111000001#10000011311000001#1000001110
INVALID
100000000000000000000000000111000001#10000011211000001#1000001110
INVALID
32################################################################
VALID
Mines cannot be placed outside of the $$$8 \times 8$$$ grid. Numbers written on revealed corner squares count the number of mines in the three squares adjacent to that corner, and similarly for numbers written on revealed edge squared.
If there are fewer than $$$M$$$ hidden squares, the board is INVALID.
A game of Mini Minesweeper is played on an $$$8 \times 8$$$ grid. At the start of the game, each square of the grid is either hidden or revealed. Exactly $$$M$$$ of the hidden squares contain mines; the others are empty. Written on each revealed square is a number between $$$0$$$ and $$$8$$$ inclusive: the number of hidden cells adjacent to the square (in the four orthogonal and four diagonal directions) that contain a mine.
You are helping your friend debug their Mini Minesweeper implementation, and so you need to write a checker for the initial board state. The checker should analyze the board and decide: is there a possible placement of the $$$M$$$ mines in hidden squares so that all of the numbers written on the revealed squares correctly identify the number of adjacent mines?
The first line of input contains a positive integer $$$M \leq 64$$$: the number of mines distributed throughout the hidden squares of the game board.
The following eight lines contain eight characters each and describe the initial game board. Each character is either #, indicating a hidden square, or a digit 0 through 8, indicating a revealed square with that digit written on it.
Print VALID if there exists some placement of $$$M$$$ mines in the hidden squares so that every number written on a revealed square correctly identifies the number of neighboring mines. Print INVALID otherwise.
27#######34##54#######3###4#7544#22####21114##3#00#3#42#11##2#11#1
VALID
200000000000000000000000000111000001#10000011311000001#1000001110
INVALID
100000000000000000000000000111000001#10000011211000001#1000001110
INVALID
32################################################################
VALID
Mines cannot be placed outside of the $$$8 \times 8$$$ grid. Numbers written on revealed corner squares count the number of mines in the three squares adjacent to that corner, and similarly for numbers written on revealed edge squared.
If there are fewer than $$$M$$$ hidden squares, the board is INVALID.