Codeforces
文章平均质量分 76
Amumu35
//我相信所有的美好都会不期而遇..
展开
-
Day 53 A. Sequence with Digits
ProblemLet’s define the following recurrence:an+1=an+minDigit(an)⋅maxDigit(an).Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes.For examples refer to notes.Your task is calcu原创 2021-09-04 12:35:54 · 119 阅读 · 0 评论 -
Day 52 B. Sorted Adjacent Differences
ProblemYou have array of n numbers a1,a2,…,an.Rearrange these numbers to satisfy |a1−a2|≤|a2−a3|≤…≤|an−1−an|, where |x| denotes absolute value of x. It’s always possible to find such rearrangement.Note that all numbers in a are not necessarily different原创 2021-09-03 12:12:36 · 96 阅读 · 0 评论 -
Day 51 B. Dreamoon and WiFi
ProblemDreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon’s smartphone and Dreamoon follows them.Each command is one of the following two types:Go 1 unit towards the positive direction原创 2021-09-02 17:51:28 · 110 阅读 · 0 评论 -
Day 50 B. Ternary String
ProblemYou are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.A contiguous substring of string s is a string原创 2021-09-01 19:17:45 · 129 阅读 · 0 评论 -
Day 49 C. Exams
ProblemStudent Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take severa原创 2021-08-31 22:22:51 · 139 阅读 · 0 评论 -
Day 48 C. Product of Three Numbers
ProblemYou are given one integer number n. Find three distinct integers a,b,c such that 2≤a,b,c and a⋅b⋅c=n or say that it is impossible to do it.If there are several answers, you can print any.You have to answer t independent test cases.InputThe firs原创 2021-08-30 16:45:59 · 78 阅读 · 0 评论 -
Day 47 D. Same Differences
ProblemYou are given an array a of n integers. Count the number of pairs of indices (i,j) such that i<j and aj−ai=j−i.InputThe first line contains one integer t (1≤t≤10^4). Then t test cases follow.The first line of each test case contains one integ原创 2021-08-29 15:01:46 · 89 阅读 · 0 评论 -
Day 46 C. Boats Competition
ProblemThere are n people who want to participate in a boat competition. The weight of the i-th participant is wi. Only teams consisting of two people can participate in this competition. As an organizer, you think that it’s fair to allow only teams with原创 2021-08-28 23:29:29 · 188 阅读 · 0 评论 -
Day 45 D. Buying Shovels
ProblemPolycarp wants to buy exactly n shovels. The shop sells packages with shovels. The store has k types of packages: the package of the i-th type consists of exactly i shovels (1≤i≤k). The store has an infinite number of packages of each type.Polycar原创 2021-08-27 23:50:51 · 103 阅读 · 0 评论 -
Day 44 D. Anti-Sudoku
ProblemYou are given a correct solution of the sudoku puzzle. If you don’t know what is the sudoku, you can read about it here.The picture showing the correct sudoku solution:Blocks are bordered with bold black color.Your task is to change at most 9 e原创 2021-08-26 15:50:35 · 103 阅读 · 0 评论 -
Day 43 B. K-th Beautiful String
ProblemFor the given integer n (n>2) let’s write down all the strings of length n which contain n−2 letters ‘a’ and two letters ‘b’ in lexicographical (alphabetical) order.Recall that the string s of length n is lexicographically less than string t of原创 2021-08-25 09:17:20 · 130 阅读 · 0 评论 -
Day 42 A. Pashmak and Garden
ProblemPashmak has fallen in love with an attractive girl called Parmida since one year ago…Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden原创 2021-08-24 16:14:06 · 131 阅读 · 0 评论 -
Day 41 C. Ternary XOR
ProblemA number is ternary if it contains only digits 0, 1 and 2. For example, the following numbers are ternary: 1022, 11, 21, 2002.You are given a long ternary number x. The first (leftmost) digit of x is guaranteed to be 2, the other digits of x can b原创 2021-08-23 13:02:29 · 100 阅读 · 0 评论 -
Day 40 B. Same Parity Summands
ProblemYou are given two positive integers n (1≤n≤10^9) and k (1≤k≤100). Represent the number n as the sum of k positive integers of the same parity (have the same remainder when divided by 2).In other words, find a1,a2,…,ak such that all ai>0, n=a1+a原创 2021-08-22 10:25:48 · 140 阅读 · 0 评论 -
Day 39 A. Odd Selection
ProblemShubham has an array a of size n, and wants to select exactly x elements from it, such that their sum is odd. These elements do not have to be consecutive. The elements of the array are not guaranteed to be distinct.Tell him whether he can do so.原创 2021-08-21 10:51:10 · 100 阅读 · 0 评论 -
Day 38 B. Random Teams
Problemn participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.Your task is to write a program that will fi原创 2021-08-20 11:07:18 · 104 阅读 · 0 评论 -
Day 37 C. Kefa and Park
ProblemKefa decided to celebrate his first big salary by going to the restaurant.He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa’s house. Unfortunaely for our hero, th原创 2021-08-19 12:05:49 · 147 阅读 · 0 评论 -
Day 36 C. Number of Ways
ProblemYou’ve got array a[1], a[2], …, a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same.More formally, you need to find the nu原创 2021-08-18 15:46:26 · 78 阅读 · 0 评论 -
Day 35 A. Two Substrings
ProblemYou are given string s. Your task is to determine if the given string s contains two non-overlapping substrings “AB” and “BA” (the substrings can go in any order).InputThe only line of input contains a string s of length between 1 and 10^5 consis原创 2021-08-17 09:29:39 · 173 阅读 · 0 评论 -
Day 34 B. Books
ProblemWhen Valera has got some free time, he goes to the library to read some books. Today he’s got t free minutes to read. That’s why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let’s number原创 2021-08-16 13:50:36 · 101 阅读 · 0 评论 -
Day 33 B. Pashmak and Flowers
ProblemPashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn’t want to have the two most beautiful flowers necessarily.原创 2021-08-15 10:37:11 · 134 阅读 · 0 评论 -
Day 32 B. Sort the Array
ProblemBeing a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.Unfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger arra原创 2021-08-14 12:02:23 · 148 阅读 · 0 评论 -
Day 31 C. Alternating Subsequence
ProblemRecall that the sequence b is a a subsequence of the sequence a if b can be derived from a by removing zero or more elements without changing the order of the remaining elements. For example, if a=[1,2,1,3,1,2,1], then possible subsequences are: [1原创 2021-08-13 11:16:25 · 137 阅读 · 0 评论 -
Day 30 B. Worms
ProblemIt is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are lab原创 2021-08-12 11:45:15 · 151 阅读 · 0 评论 -
Day 29 C. K-th Not Divisible by n
ProblemYou are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.For example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1,2,4,5,7,8,10,11,13…. The 7-th number among them is 10.Input原创 2021-08-11 11:16:39 · 132 阅读 · 0 评论 -
Day 28 A. Flipping Game
ProblemIahub got bored, so he invented a game to be played on paper.He writes n integers a1, a2, …, an. Each of those integers can be either 0 or 1. He’s allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and flips all values原创 2021-08-10 10:20:25 · 115 阅读 · 0 评论 -
Day 27 B. Two Buttons
ProblemVasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the bl原创 2021-08-09 11:25:26 · 74 阅读 · 0 评论 -
Day 26 B. BerSU Ball
ProblemThe Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves.We know that several boy&girl pairs are going to原创 2021-08-08 00:53:07 · 179 阅读 · 0 评论 -
Day 24 C. Given Length and Sum of Digits...
ProblemYou have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base wi原创 2021-08-07 15:41:43 · 93 阅读 · 0 评论 -
Day 24 A. Cheap Travel
ProblemAnn has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will n原创 2021-08-06 10:35:00 · 303 阅读 · 0 评论 -
Day 23 A. Boredom
ProblemAlex doesn’t like boredom. That’s why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single原创 2021-08-05 11:50:21 · 129 阅读 · 0 评论 -
Day 22 A. Cut Ribbon
ProblemPolycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions:After the cutting each ribbon piece should have length a, b or c.After the cutting the number of ribbon pieces should be maxim原创 2021-08-04 10:29:36 · 158 阅读 · 0 评论 -
Day 21 B. T-primes
ProblemWe know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we’ll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers.原创 2021-08-03 09:20:05 · 152 阅读 · 0 评论 -
Day 20 C. Registration system
ProblemA new e-mail service “Berlandesk” is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that’s why they ask you to help. You’re suggested to implement the prototype of site r原创 2021-08-02 11:05:20 · 90 阅读 · 0 评论 -
Day 19 B. Flip the Bits
Problem:There is a binary string a of length n. In one operation, you can select any prefix of a with an equal number of 0 and 1 symbols. Then all symbols in the prefix are inverted: each 0 becomes 1 and each 1 becomes 0.For example, suppose a=0111010000原创 2021-08-01 10:09:17 · 147 阅读 · 0 评论 -
Day 18 C. Coin Rows
Problem:Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains ai,j coins in it.Initially, both Alice and Bob are standing in a cell (1,1). They are going to perform a sequen原创 2021-07-31 20:35:03 · 222 阅读 · 0 评论 -
Day 17 B. Cobb
Problem:You are given n integers a1,a2,…,an and an integer k. Find the maximum value of i⋅j−k⋅(ai | aj) over all pairs (i,j) of integers with 1≤i<j≤n.InputThe first line contains a single integer t (1≤t≤10000) — the number of test cases.The first l原创 2021-07-30 14:52:18 · 176 阅读 · 0 评论 -
Day 16 B. Spreadsheets
Problem:In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 ha原创 2021-07-29 12:30:29 · 123 阅读 · 0 评论 -
Day 15 B. Running for Gold
Problem:The Olympic Games have just started and Federico is eager to watch the marathon race.There will be n athletes, numbered from 1 to n, competing in the marathon, and all of them have taken part in 5 important marathons, numbered from 1 to 5, in the原创 2021-07-28 11:10:08 · 127 阅读 · 0 评论 -
Day 14 E. Two Round Dances
Problem:One day, n people (n is an even number) met on a plaza and made two round dances, each round dance consists of exactly n/2 people. Your task is to find the number of ways n people can make two round dances if each round dance consists of exactly n原创 2021-07-27 14:04:48 · 144 阅读 · 0 评论