codeforces round 26前两题水题

来源:互联网 发布:工资条发放软件 编辑:程序博客网 时间:2024/06/03 13:06
水题,没必要往这儿放的,只是保存一下而已 ,哎,后边的就不会写了……郁闷
A. Almost Prime
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and n, inclusive.

Input

Input contains one integer number n (1 ≤ n ≤ 3000).

Output

Output the amount of almost prime numbers between 1 and n, inclusive.

Sample test(s)
Input
10
Output
2
Input
21
Output
8

B. Regular Bracket Sequence
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not.

One day Johnny got bracket sequence. He decided to remove some of the brackets from it in order to obtain a regular bracket sequence. What is the maximum length of a regular bracket sequence which can be obtained?

Input

Input consists of a single line with non-empty string of "(" and ")" characters. Its length does not exceed 106.

Output

Output the maximum possible length of a regular bracket sequence.

Sample test(s)
Input
(()))(
Output
4
Input
((()())
Output

6


原创粉丝点击