جلوه هایی از المپیاد کامپیوتر

Aspects of Olympiad in Informatics | A O I

جلوه هایی از المپیاد کامپیوتر

Aspects of Olympiad in Informatics | A O I

Clock second-hand Clock minute-hand Clock hour-hand
جلوه هایی از المپیاد کامپیوتر
پنجشنبه, ۷ دی ۱۳۹۱، ۰۸:۳۵ ب.ظ

برنامه نویسی << شماره 4 >>

1 )

Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If there are at least 7 players of some team standing one after another, then the situation is considered dangerous. For example, the situation 00100110111111101 is dangerous and 11110111011101 is not. You are given the current situation. Determine whether it is dangerous or not.

Input

The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field.

Output

Print "YES" if the situation is dangerous. Otherwise, print "NO".

Sample test(s)
input
001001
output
NO
input
1000000001
output
YES

2 )

Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to the store and buy some few more horseshoes, not to lose face in front of his stylish comrades.

Fortunately, the store sells horseshoes of all colors under the sun and Valera has enough money to buy any four of them. However, in order to save the money, he would like to spend as little money as possible, so you need to help Valera and determine what is the minimum number of horseshoes he needs to buy to wear four horseshoes of different colors to a party.

Input

The first line contains four space-separated integers s1, s2, s3, s4 (1 ≤ s1, s2, s3, s4 ≤ 109) — the colors of horseshoes Valera has.

Consider all possible colors indexed with integers.

Output

Print a single integer — the minimum number of horseshoes Valera needs to buy.

Sample test(s)
input
1 7 3 3
output
1
input
7 7 7 7
output
3

3 )

Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he organized a New Year party at his place and invited n his friends there.

If there's one thing Petya likes more that receiving gifts, that's watching others giving gifts to somebody else. Thus, he safely hid the laptop until the next New Year and made up his mind to watch his friends exchanging gifts while he does not participate in the process. He numbered all his friends with integers from 1 to n. Petya remembered that a friend number i gave a gift to a friend number pi. He also remembered that each of his friends received exactly one gift.

Now Petya wants to know for each friend i the number of a friend who has given him a gift.

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the quantity of friends Petya invited to the party. The second line contains nspace-separated integers: the i-th number is pi — the number of a friend who gave a gift to friend number i. It is guaranteed that each friend received exactly one gift. It is possible that some friends do not share Petya's ideas of giving gifts to somebody else. Those friends gave the gifts to themselves.

Output

Print n space-separated integers: the i-th number should equal the number of the friend who gave a gift to friend number i.

Sample test(s)
input
4
2 3 4 1
output
4 1 2 3
input
3
1 3 2
output
1 3 2
input
2
1 2
output
1 2

4 )

The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are arranged in a circle at equal distances from each other, so they form a regular n-gon. They are numbered in clockwise order with numbers from 1 ton.

The site of the University has already conducted a voting that estimated each sculpture's characteristic of ti — the degree of the sculpture's attractiveness. The values of ti can be positive, negative or zero.

When the university rector came to evaluate the work, he said that this might be not the perfect arrangement. He suggested to melt some of the sculptures so that:

  • the remaining sculptures form a regular polygon (the number of vertices should be between 3 and n),
  • the sum of the ti values of the remaining sculptures is maximized.

Help the Vice Rector to analyze the criticism — find the maximum value of ti sum which can be obtained in this way. It is allowed not to melt any sculptures at all. The sculptures can not be moved.

Input

The first input line contains an integer n (3 ≤ n ≤ 20000) — the initial number of sculptures. The second line contains a sequence of integers t1, t2, ..., tnti — the degree of the i-th sculpture's attractiveness ( - 1000 ≤ ti ≤ 1000). The numbers on the line are separated by spaces.

Output

Print the required maximum sum of the sculptures' attractiveness.

Sample test(s)
input
8
1 2 -3 4 -5 5 2 3
output
14
input
6
1 -2 3 -4 5 -6
output
9
input
6
1 2 3 4 5 6
output
21
موافقین ۲ مخالفین ۱ ۹۱/۱۰/۰۷
آرمان غفاری

codeforces

برنامه نویسی

نظرات (۲)

چه سوالای خوبی گذاشتی.فر کنم اینارو کدفورسس از تو کپی می کنه.درضمن نمایش یا بازدید مهم نیست.مفید بودن مهمه که وبلاگ تو به زور در این مورد0.00000001وبلاگ منم نمیشه
پاسخ:
خوب بلاگ من که تو سوالات خیلی مفیده !!! بلاگ منم توی سوالات از بلاگ تو خیلی خفن تره !!!

D:
۰۸ دی ۹۱ ، ۱۶:۰۹ سپهر محمدی
میشه ترجمه کنید؟
پاسخ:
سلام . یه المپیادی خوب باید خودش ترجمه کنه !!!!

باشه حالا اگه نتونستی بگو تا بذارم .

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">