过去, 把眼前的穷人培训成将来的劳工的观点在经济上和政治上都是合理的. 它促进了工业经济的发展, 充分的满足了秩序维护和规范法规之间融合需要. 在现代化后期, 后现代, 尤其是在消费社会, 这两个作用都难以继续存在. 现代经济不再需要大量劳动力, 它已经学会在减少劳动力和支出的同时如何增加产量和利润. 同时, 对社会规范和社会规定的服从很大程度上是靠商品市场的吸引和诱惑, 而不是靠国家的强制和各种庞杂的社会机构的灌输来保证的. 在经济上和政治上, 现代化后期或后现代消费社会在不拖着大部分成员经受工业劳动的沉重负担下仍能繁荣发展. 从实用目的来看, 穷人已经不再是劳动力的后备力量, 职业道德的呼声听起来越来越模糊, 与现实脱离了联系.
当代社会首先把它的成员当作消费者, 然后部分的把他们作为生产者. 为了符合社会规范的要求, 完全成为社会的一员, 社会成员要快速积极的购买消费市场的商品, 为清理商品供应的要求作出贡献, 在经济出现问题的时候成为“消费者为主导的复苏”的一部分. 这些, 对于没有可观收入, 信用卡, 舒适生活前景的穷人来说, 是不可能的. 因此, 被今天的穷人破坏的规范(破坏这些规范会使规范本身反常)是消费者能力或者才能的规范, 而不是职业规范. 最重要的是, 今天的穷人是“不消费的人”而不是“失业者”; 他们首先被定义为有缺陷的消费者, 因为他们没有履行社会责任中最重要的部分, 也就是说, 成为市场提供的商品和服务的积极购买者. 在消费社会的账目平衡中, 穷人无疑是负债, 无论怎样, 他们都不能被记录在现在或者将来的资产簿中.
因此, 在历史上, 穷人第一次绝对的, 完全的成了让人担忧, 让人讨厌的人, 他们没有任何益处, 能够减轻以至抵消他们的恶习. 他们不能提供和纳税人交的税一样的东西. 他们是一项错误的投资, 把所有周围的吸入进来, 却可能除了麻烦什么也不吐出来. 社会中那些体面的, 符合规范的成员——那些“消费者”——对穷人没有任何要求和期待. 穷人完全没有用处., 没有人真正的把穷人考虑在内, 公开讲需要穷人. 对穷人, “零容忍”. 如果穷人不再存在, 社会将更加富有, 事业也会更加美好. 这个世界不需要穷人, 穷人的存在没有任何必要. 所以, 将穷人遗弃不必有任何懊悔和内疚.
]]>把工作同时尊为最高职责, 道德礼仪的状态, 法律与秩序的保证, 以及贫穷瘟疫的良方, 它与劳动密集型工业相适应, 呼吁增加劳动力以增加产量. 如今简化, 精简, 资本和知识密集型工业则把劳动力视为提高生产力的限制性因素. 在对曾被奉为权威的斯密——李嘉图——马克思的劳动价值论的直接挑战中, 过剩的劳动力被当作受谴责的对象, 所有理性化(更高的投入产出比)探索都首先将可能性聚焦在减少雇员数量上面. 从所有现实的意图出发, “经济增长”和就业率的提高是南辕北辙的: 技术进步以代替和消除劳动力的标准来衡量. 在如此情形之下, 工作伦理的训诫与诱惑日益变得空洞. 他们不再反映“工业需求”, 也几乎不能被视作为“国家的财富”的钥匙. 他们的持续, 更确切的说是他们近来在政治话语中的复苏, 也只能从这样的角度进行解释: 工作伦理被寄希望于在我们这个后工业, 消费者社会的时代中发挥一些新的作用.
正如弗吉和米勒的观点, 近来鼓吹工作伦理的复兴, 服务于这样的思维: “区分值得帮助和不值得帮助的穷人, 归咎于过去, 以证明社会对其的漠不关心”. 因此“接受贫穷是由个人缺陷所不可避免带来的灾祸, 继之以对穷人和被剥夺着冷漠无情”. 换言之, 即使工作伦理不再为减少贫穷提供途径, 仍可以调和社会与永远存在的穷人之间的关系, 从而使社会能一如既往和平安宁的生存下去.
]]>Let f(n) be a sum of digits for positive integer n. If f(n) is onedigit number then it is a digital root for n and otherwise digital root of n is equal to digital root of f(n). For example, digital root of 987 is 6. Your task is to find digital root for expression A1*A2*...*AN + A1*A2*...*AN1 + ... + A1*A2 + A1
.
Input file consists of few test cases. There is K (1<=K<=5) in the first line of input. Each test case is a line. Positive integer number N is written on the first place of test case (N<=1000). After it there are N positive integer numbers (sequence A). Each of this numbers is nonnegative and not more than 109.
Write one line for every test case. On each line write digital root for given expression.
1  1 
1  5 
1 

You are given an undirected connected graph, with N vertices and N1 edges (a tree). You must find the centroid(s) of the tree.
In order to define the centroid, some integer value will be assosciated to every vertex. Let’s consider the vertex k. If we remove the vertex k from the tree (along with its adjacent edges), the remaining graph will have only N1 vertices and may be composed of more than one connected components. Each of these components is (obviously) a tree. The value associated to vertex k is the largest number of vertices contained by some connected component in the remaining graph, after the removal of vertex k. All the vertices for which the associated value is minimum are considered centroids.
The first line of the input contains the integer number N (1<=N<=16 000). The next N1 lines will contain two integers, a and b, separated by blanks, meaning that there exists an edge between vertex a and vertex b.
You should print two lines. The first line should contain the minimum value associated to the centroid(s) and the number of centroids. The second line should contain the list of vertices which are centroids, sorted in ascending order.
1  7 
1  3 1 
1 

His Royal Highness King of Berland Berl XV was a very wise man and had a very accomplished wife, who was aware of the fact, that prominent and outstanding personalities once having written down their names on the pages of glorious History, remain there forever. His Royal Highness King Berl XV experienced an intrinsic, lost nowadays, deep and sincere sense of respect and trust for his beloved spouse. So he decided to acquire a chronicler of his own. Due to the ambiguous nature of misunderstanding and the crying injustice of history to ambiguity, he decided to leave all his royal responsibilities aside and made up his royal mind to find the chronicler, who will make him famous, depicting all his heroic deeds truthfully and gloriously enough.
The King assembled the greatest minds of his kingdom at the Academic Chroniclers Meeting (ACM), as he named it, and decided to test their might. The task was to build the Smallest Lexicographical Concatenation (SLC) out of the given N strings. SLC of N strings s1,…, sN is the lexicographically smallest their concatenation si1 +… + siN, where i1,…, iN is a permutation of integers from 1 through N. It’s a great privilege to be a chronicler, so don’t miss your chance and don’t screw it up! Make the king choose you!
The first line of the input file contains a single integer N (1 ≤ N ≤ 100) indicating the number of strings. The following N lines contain N strings, one string per line. The length of each string is no more than 100 characters. Each string consists only of lowercase Latin letters. There are no any leading or trailing spaces.
Print the SLC of the given N strings to the output file as a single line.
sample input  sample output 
6 it looks like an easy problem  aneasyitlikelooksproblem 
1 

You want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least as many vases ordered in a row. The vases are glued onto the shelf and are numbered consecutively 1 through V, where V is the number of vases, from left to right so that the vase 1 is the leftmost, and the vase V is the rightmost vase. The bunches are moveable and are uniquely identified by integers between 1 and F. These idnumbers have a significance: They determine the required order of appearance of the flower bunches in the row of vases so that the bunch i must be in a vase to the left of the vase containing bunch j whenever i < j. Suppose, for example, you have bunch of azaleas (idnumber=1), a bunch of begonias (idnumber=2) and a bunch of carnations (idnumber=3). Now, all the bunches must be put into the vases keeping their idnumbers in order. The bunch of azaleas must be in a vase to the left of begonias, and the bunch of begonias must be in a vase to the left of carnations. If there are more vases than bunches of flowers then the excess will be left empty. A vase can hold only one bunch of flowers.
Each vase has a distinct characteristic (just like flowers do). Hence, putting a bunch of flowers in a vase results in a certain aesthetic value, expressed by an integer. The aesthetic values are presented in a table as shown below. Leaving a vase empty has an aesthetic value of 0.
V A S E S  
1  
Bunches  1 (azaleas)  7 
2 (begonias)  5  
3 (carnations)  21 
According to the table, azaleas, for example, would look great in vase 2, but they would look awful in vase 4.
To achieve the most pleasant effect you have to maximize the sum of aesthetic values for the arrangement while keeping the required ordering of the flowers. If more than one arrangement has the maximal sum value, any one of them will be acceptable. You have to produce exactly one arrangement.
1 ≤ F ≤ 100 where F is the number of the bunches of flowers. The bunches are numbered 1 through F.
F ≤ V ≤ 100 where V is the number of vases.
50 £ Aij £ 50 where Aij is the aesthetic value obtained by putting the flower bunch i into the vase j.
1  3 5 
1  53 
1 

The sequence of nonnegative integers A1, A2, …, AN is given. You are to find some subsequence Ai1, Ai2, …, Aik (1 <= i1 < i2 < … < ik <= N) such, that Ai1 XOR Ai2 XOR … XOR Aik has a maximum value.
The first line of the input file contains the integer number N (1 <= N <= 100). The second line contains the sequence A1, A2, …, AN (0 <= Ai <= 10^18).
Write to the output file a single integer number – the maximum possible value of Ai1 XOR Ai2 XOR … XOR Aik.
3
11 9 5
14
1 

Five silent philosophers sit at a round table with bowls of spaghetti. Forks are placed between each pair of adjacent philosophers.
Each philosopher must alternately think and eat. However, a philosopher can only eat spaghetti when they have both left and right forks. Each fork can be held by only one philosopher and so a philosopher can use the fork only if it is not being used by another philosopher. After an individual philosopher finishes eating, they need to put down both forks so that the forks become available to others. A philosopher can take the fork on their right or the one on their left as they become available, but cannot start eating before getting both forks.
Eating is not limited by the remaining amounts of spaghetti or stomach space; an infinite supply and an infinite demand are assumed.
Design a discipline of behavior (a concurrent algorithm) such that no philosopher will starve; i.e., each can forever continue to alternate between eating and thinking, assuming that no philosopher can know when others may want to eat or think.
The problem statement and the image above are taken from wikipedia.org
The philosophers’ ids are numbered from 0 to 4 in a clockwise order. Implement the function void wantsToEat(philosopher, pickLeftFork, pickRightFork, eat, putLeftFork, putRightFork) where:
Five threads, each representing a philosopher, will simultaneously use one object of your class to simulate the process. It is possible that the function will be called for the same philosopher more than once, even before the last call ends.
Example 1:
1 

Constraints:
1 

Write a program that outputs the string representation of numbers from 1 to n, however:
For example, for n = 15, we output: 1, 2, fizz, 4, buzz, fizz, 7, 8, fizz, buzz, 11, fizz, 13, 14, fizzbuzz.
Suppose you are given the following code:
1  class FizzBuzz { 
Implement a multithreaded version of FizzBuzz with four threads. The same instance of FizzBuzz will be passed to four different threads:
1  class FizzBuzz { 
There are two kinds of threads, oxygen and hydrogen. Your goal is to group these threads to form water molecules. There is a barrier where each thread has to wait until a complete molecule can be formed. Hydrogen and oxygen threads will be given releaseHydrogen and releaseOxygen methods respectively, which will allow them to pass the barrier. These threads should pass the barrier in groups of three, and they must be able to immediately bond with each other to form a water molecule. You must guarantee that all the threads from one molecule bond before any other threads from the next molecule do.
In other words:
Write synchronization code for oxygen and hydrogen molecules that enforces these constraints.
Example 1:
1  Input: "HOH" 
Example 2:
1  Input: "OOHHHH" 
Constraints:
1  class H2O { 
Suppose you are given the following code:
1  class ZeroEvenOdd { 
The same instance of ZeroEvenOdd will be passed to three different threads:
Each of the threads is given a printNumber method to output an integer. Modify the given program to output the series 010203040506… where the length of the series must be 2n.
Example 1:
1  Input: n = 2 
Example 2:
1  Input: n = 5 
1  class ZeroEvenOdd { 
Find amount of numbers for given sequence of integer numbers such that after raising them to the Mth power they will be divided by K.
Input consists of two lines. There are three integer numbers N, M, K (0<N, M, K<10001) on the first line. There are N positive integer numbers − given sequence (each number is not more than 10001) − on the second line.
Write answer for given task.
1  4 2 50 
1  1 
1 

Social networks are very popular now. They use different types of relationships to organize individual users in a network. In this problem friendship is used as a method to connect users. For each user you are given the list of his friends. Consider friendship as a symmetric relation, so if user a is a friend of user b then b is a friend of a.
A friend of a friend for a is such a user c that c is not a friend of a, but there is such b that b is a friend of a and c is a friend of b. Obviously c ≠ a.
Your task is to find the list of friends of friends for the given user x.
The first line of the input contains integer numbers N and x (1 ≤ N ≤ 50, 1 ≤ x ≤ N), where N is the total number of users and x is user to be processed. Users in the input are specified by their numbers, integers between 1 and N inclusive. The following N lines describe friends list of each user. The ith line contains integer di (0 ≤ di ≤ 50) — number of friends of the ith user. After it there are di distinct integers between 1 and N — friends of the ith user. The list doesn’t contain i. It is guaranteed that if user a is a friend of user b then b is a friend of a.
You should output the number of friends of friends of x in the first line. Second line should contain friends of friends of x printed in the increasing order.
sample input  sample output 

4 2 1 2 2 1 3 2 4 2 1 3  1 4 
sample input  sample output 

4 1 3 4 3 2 3 1 3 4 3 1 2 4 3 1 2 3  0 
1 

Along the border between states A and B there are N defence outposts. For every outpost k, the interval [Ak,Bk] which is guarded by it is known. Because of financial reasons, the president of country A decided that some of the outposts should be abandoned. In fact, all the redundant outposts will be abandoned. An outpost i is redundant if there exists some outpost j such that Aj<Ai and Bi<Bj. Your task is to find the number of redundant outposts.
The first line of the input will contain the integer number N (1<=N<=16 000). N lines will follow, each of them containing 2 integers: Ak and Bk (0<= Ak < Bk <= 2 000 000 000), separated by blanks. All the numbers Ak will be different. All the numbers Bk will be different.
You should print the number of redundant outposts.
1  5 
1  3 
1 

You are given natural number X. Find such maximum integer number that it square is not greater than X.
Input file contains number X (1≤X≤10^1000).
Write answer in output file.
16
4
1  if __name__ == '__main__': 
Little Johnny likes to draw a lot. A few days ago he painted lots of straight lines on his sheet of paper. Then he counted in how many zones the sheet of paper was split by these lines. He noticed that this number is not always the same. For instance, if he draws 2 lines, the sheet of paper could be split into 4, 3 or even 2 (if the lines are identical) zones. Since he is a very curious kid, he would like to know which is the maximum number of zones into which he can split the sheet of paper, if he draws N lines. The sheet of paper is to be considered a very large (=infinite) rectangle.
The input file will contain an integer number: N (0<=N<=65535).
You should output one integer: the maximum number of zones into which the sheet of paper can be split if Johnny draws N lines.
0
1
1
2
1 

Famous Berland ACMICPC team Anisovka consists of three programmers: Andrew, Michael and Ilya. A long time ago, during the first few months the team was founded, Andrew was very often late to the trainings and contests. To stimulate Andrew to be more punctual, Ilya and Andrew decided to introduce a new rule for team participants. If somebody is late (i.e. comes at least one second after appointed time) he owes a cup of tea to other team members. If he is late for 5 minutes, he owes two cups of tea. If he is late for 15 minutes, he owes three cups of tea. And if he is late for 30 minutes or more, he owes 4 cups of tea.
The training starts at the time S (counted in seconds, from some predefined moment of time) and Andrew comes at the time P (also in seconds, counted from the same moment of time).
Your task is to find how many cups of tea Andrew owes.
The input file contains single line with integer numbers S and P (0 <= S,P <= 10^4).
Write to the output file the number of cups Andrew owes.
10 10
10 11
0 300
0
1
2
1 

Inspired by a “Little Bishops” problem, Petya now wants to solve problem for rooks.
A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move horizontally and vertically from its current position and two rooks attack each other if one is on the path of the other.
Given two numbers n and k, your job is to determine the number of ways one can put k rooks on an n × n chessboard so that no two of them are in attacking positions.
The input file contains two integers n (1 ≤ n ≤ 10) and k (0 ≤ k ≤ n2).
Print a line containing the total number of ways one can put the given number of rooks on a chessboard of the given size so that no two of them are in attacking positions.
4 4
24
1 

First year of new millenium is gone away. In commemoration of it write a program that finds the name of the day of the week for any date in 2001.
Input is a line with two positive integer numbers N and M, where N is a day number in month M. N and M is not more than 100.
Write current number of the day of the week for given date (Monday – number 1, … , Sunday – number 7) or phrase “Impossible” if such date does not exist.
21 10
7
1 

For given number N you must output amount of Ndigit numbers, such, that last digits of their square is equal to 987654321.
Input contains integer number N (1<=N<=106)
Write answer to the output.
8
0
1 
