编程大赛-4
OSL
After invoking appl start command, n osl processes are going to be started. Each process requires certain amount of CPU time units to be successfully initiated. Of course, CPU can run a process for a few time units, then switch to another one and finally get back to the previous process to let it go. A dedicated sysMonitor application is scheduled to verify whether each osl process is successfully initiated.
Input: (standard input)
+Line 1 contains: n, 1 ≦ n ≦ 100 000.
+Line i + 1, (where 1 ≦ i ≦ n) of standard input describes i-th process. It contains two space-separated integers: pi and si, where 1 ≦ pi , si ≦ 1000000000. These numbers mean that i-th process requires pi CPU time units to be successfully initiated, andsysMonitor is going to check whether i-th process is initiated at si time units followappl_start.
Output: (standard output)
Your program should print out the maximum number of osl processes which can be successfully initiated and verified by sysMonitor application.
Example:
For sample input:
4
4 6
1 2
2 3
2 1
a correct output format:
2
___________________________
|
xy-game
|
Let us define the following sequence of xy-words {wi}i>=0, w0 = x, w1 = y, wi = wi-2 ⊕wi-1 for i >1, where symbol ⊕ denotes concatenation of words. So we have xy-words: x, y, xy, yxy, xyyxy, etc.
You play the following xy-game against your opponent n times. There is a starting word consisting of only x and y letters. In the first move you must cross out any xy-word from the end of the given word. After your turn, the opponent crosses out an xy-word from the end of the word you left, and then it is your turn and so on. The player which crosses out the last xy-word wins. Your opponent plays optimally, that is, once given a chance, he/she will win and you will lose.
Input: (standard input)
+Line 1 contains one integer n, where 1 <= n <= 10, (this is a number of words)
+Line 1 + i, (1 <= i <= n) contains a length of a word followed by the word. Length is not greater than 100000.
Output: (standard output)
Your program should write in a separate line a result for each word; 1 when you are going to win, 0 otherwise.
Example:
For sample input:
3
3 xyx
5 xyyxy
4 yxxy
a correct output format:
0
1
1
|
SIGBIT signal handler
|
Suppose we have a sequence of n bits (0 and/or 1). SIGBIT signal comes every second, then SignalHandler() immediately adjusts all bits. The handler follows the rule: the i-thbit is changed whenever (i + 1)-th bit was 1 after the previous signal dispatch (1 <= i < n). The value of the last (nth) bit is changed if the first bit was 1 after the previous signal dispatch. Write a program that prints out the sequence after SIGBIT signal comes s times.
Input: (standard input)
+Line 1 contains two space separated integers: n s, 1 < n < 100 000, 0 < s < 231.
+Line 2 contains a sequence of bits, i.e.: n space separated zeroes or ones.
Output: (standard output)
Your program should print out the sequence of bits after receiving s SIGBIT signals. Bits should be space separated.
Example:
For sample input:
5 4
0 1 1 0 0
a correct output format:
0 1 0 1 0
________________________________________________________________________
Hint:
0 1 1 0 0 starting point
1 0 1 0 0 after 1st SIGBIT signal
1 1 1 0 1 after 2nd signal
0 0 1 1 0 after 3rd signal
0 1 0 1 0 after 4th signal

浙公网安备 33010602011771号