#P4832. 珈百璃堕落的开始

珈百璃堕落的开始

Description

The problem is as follows: given some expressions composed of sin2x\sin^2 x and cos2x\cos^2 x with x=π7x=\dfrac{\pi}{7}, please find the maximum integer value you can obtain by selecting some of the expressions and summing them.

Input Format

The first line contains an integer nn, indicating nn expressions.

Each of the next nn lines contains a string formed by f(i)=sin2xf(i)=\sin^2 x, cos2x\cos^2 x and plus signs, with x=π7x=\dfrac{\pi}{7}.

To simplify the input, we use s to represent sin2x\sin^2 x, c to represent cos2x\cos^2 x, and omit f(i)=.

Output Format

Output a single number representing the maximum integer answer. All operations are addition.

3
s+c
s+c+s
c

3

Hint

Sample Explanation:

  • If you pick all three expressions, their sum equals 33.

Constraints:

  • Let the total count of s and c be mm.
  • For 10%10\% of the testdata, n=1n=1.
  • For another 20%20\% of the testdata, each line is a single-term expression.
  • For another 20%20\% of the testdata, n20n \le 20.
  • For 100%100\% of the testdata, n×m5×107n \times m \le 5 \times 10^7, m106m \le 10^6.

Tips:

  • x, sin2x+cos2x=1\forall x,\ \sin^2 x + \cos^2 x = 1.

Translated by ChatGPT 5