#P17189. [ICPC 2017 Hong Kong R] Count the Even Integers

    ID: 16771 Type: RemoteJudge 2000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>高精度2017数位 DPLucas 定理ICPC香港bitset

[ICPC 2017 Hong Kong R] Count the Even Integers

题目描述

Yang Hui’s Triangle is defined as follows.

In the first layer, there are two numbers A1,1A_{1,1} and A1,2A_{1,2} satisfying A1,1=A1,2=1A_{1,1} = A_{1,2} = 1.

Then for each i>1i > 1, the ii-th layer contains i+1i+1 numbers satisfying Ai,1=Ai,i+1=1A_{i,1} = A_{i,i+1} = 1 and Ai,j=Ai−1,j−1+Ai−1,jA_{i,j} = A_{i-1,j-1} + A_{i-1,j} for 1<j≤i1 < j \le i.

$$\begin{matrix} 1 & 1 \\ 1 & 2 & 1 \\ 1 & 3 & 3 & 1 \\ 1 & 4 & 6 & 4 & 1 \\ 1 & 5 & 10 & 10 & 5 & 1 \\ 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\ 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 \end{matrix}$$

Now, given an integer NN, you are asked to count the number of even integers in the first NN layers.

输入格式

The input file contains multiple cases, please handle it to the end of file.

For each case, there is only one line containing an integer NN (0<N≤10500 < N \le 10^{50}).

输出格式

For each case, output the number of the even integers in the first NN layers of Yang Hui’s Triangle.

4
8
12
4
16
42