Trang website dành cho nghành điện tử ,công nghệ thông tin -Website for electronics, information technology-Nguyễn Công Trình

in y •  6 years ago 

https://practice.geeksforgeeks.org/
các bài ví dụ như :
==The Painter's Partition Problem==
Dilpreet wants to paint his dog- Buzo's home that has n boards with different lengths[A1, A2,..., An]. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.The problem is to find the minimum time to get this job done under the constraints that any painter will only paint continuous sections of boards, say board {2, 3, 4} or only board {1} or nothing but not board {2, 4, 5}.

Input:
The first line consists of a single integer T, the number of test cases. For each test case, the first line contains an integer k denoting the number of painters and integer n denoting the number of boards. Next line contains n- space separated integers denoting the size of boards.

Output:
For each test case, the output is an integer displaying the minimum time for painting that house.

Constraints:
1<=T<=100
1<=k<=30
1<=n<=50
1<=A[i]<=500

Example:
Input:
2
2 4
10 10 10 10
2 4
10 20 30 40
Output:
20
60

Explanation:

  1. Here we can divide the boards into 2 equal sized partitions, so each painter gets 20 units of the board and the total time taken is 20.
  2. Here we can divide first 3 boards for one painter and the last board for the second painter.

** For More Input/Output Examples Use 'Expected Output' option **
==Boolean String Value==
Given a string consisting of only 0, 1, A, B, C where
A = AND
B = OR
C = XOR
Calculate the value of the string assuming no order of precedence and evaluation is done from left to right.

Input:

The first line of input contains an integer T denoting the number of test cases.
The next T lines contains T strings.

Output:

Print the value of the string assuming no order of precedence and evaluation is done from left to right

Constraints:

1 ≤ T ≤ 100
1 ≤ length(string)<=1000

Examples:
Input :
1
1A0B1

Output : 1

1 AND 0 OR 1 = 1

Input :
2
1C1B1B0A0
1A0B1

Output :
0
1

** For More Input/Output Examples Use 'Expected Output' option **

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://practice.geeksforgeeks.org/problems/the-painters-partition-problem/0