随笔分类 - 题库—Codeforces比赛
摘要:You are given a rooted tree consisting of nn vertices numbered from 11 to nn . The root of the tree is a vertex number 11 . A tree is a connected undi
阅读全文
摘要:Vova had a pretty weird sleeping schedule. There are hh hours in a day. Vova will sleep exactly nn times. The ii -th time he will sleep exactly after
阅读全文
摘要:The next lecture in a high school requires two topics to be discussed. The ii -th topic is interesting by aiai units for the teacher and by bibi units
阅读全文
摘要:There is a frog staying to the left of the string s=s1s2…sns=s1s2…sn consisting of nn characters (to be more precise, the frog initially stays at the
阅读全文
摘要:The round carousel consists of nn figures of animals. Figures are numbered from 11 to nn in order of the carousel moving. Thus, after the nn -th figur
阅读全文
摘要:A number is ternary if it contains only digits 00 , 11 and 22 . For example, the following numbers are ternary: 10221022 , 1111 , 2121 , 20022002 . Yo
阅读全文
摘要:For the given integer nn (n>2n>2 ) let's write down all the strings of length nn which contain n−2n−2 letters 'a' and two letters 'b' in lexicographic
阅读全文
摘要:You are given two positive integers aa and bb. In one move you can increase aa by 11 (replace aa with a+1a+1). Your task is to find the minimum number
阅读全文
摘要:E. Count The Blocks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You wrote down all i
阅读全文
摘要:Petya has a rectangular Board of size n×mn×m . Initially, kk chips are placed on the board, ii -th chip is located in the cell at the intersection of
阅读全文
摘要:The King of Berland Polycarp LXXXIV has nn daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princ
阅读全文
摘要:You are given two integers nn and kk. Your task is to find if nn can be represented as a sum of kk distinct positive odd (not divisible by 22) integer
阅读全文
摘要:Once Petya read a problem about a bracket sequence. He gave it much thought but didn't find a solution. Today you will face it. You are given string s
阅读全文
摘要:You are given a tree consisting of nn nodes. You want to write some labels on the tree's edges such that the following conditions hold: Every label is
阅读全文
摘要:Ehab has an array aa of length nn . He has just enough free time to make a new array consisting of nn copies of the old array, written back-to-back. W
阅读全文
摘要:You are given a positive integer xx . Find any such 22 positive integers aa and bb such that GCD(a,b)+LCM(a,b)=xGCD(a,b)+LCM(a,b)=x . As a reminder, G
阅读全文
摘要:You are given an array a1,a2,…,ana1,a2,…,an . Array is good if for each pair of indexes i<ji<j the condition j−aj≠i−aij−aj≠i−ai holds. Can you shuffle
阅读全文
摘要:You are given two integers nn and mm (m<nm<n). Consider a convex regular polygon of nn vertices. Recall that a regular polygon is a polygon that is eq
阅读全文
摘要:You are given an array aa of length nn and array bb of length mm both consisting of only integers 00 and 11 . Consider a matrix cc of size n×mn×m form
阅读全文
摘要:You are given an array aa consisting of nn positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by 2
阅读全文