Beautiful Segments
You are given an array, , consisting of integers. A segment, , is beautiful if and only if the bitwise AND of all numbers in with indices in the inclusive range of is not greater than . In other words, segment is beautiful if . You must answer queries. Each query, , consists of integers: , , and . The answer for each is the number of beautiful segments such that and . Input Format The first line contains two space-separated integers, (the number of integers in ) and (the n
View Solution →White Falcon And Tree
White Falcon has a tree with nodes. Each node contains a linear function. Let's denote by the linear function contained in the node . Let's denote the path from node to node like this: , where and , and and are connected. White Falcon also has queries. They are in the following format: . Assign as the function of all the nodes on the path from to , i.e., is changed to where is the path from to . . Calculate modulo Input Format The first line contains , th
View Solution →Arithmetic Progressions
Let F(a,d) denote an arithmetic progression (AP) with first term and common difference , i.e. denotes an infinite . You are given APs => . Let denote the sequence obtained by multiplying these APs. Multiplication of two sequences is defined as follows. Let the terms of the first sequence be , and terms of the second sequence be . The sequence obtained by multiplying these two sequences is If are the terms of a sequence, then the terms of the first difference of this sequence are given b
View Solution →Burger Happiness
n Burger Town new burger restaurants will be opened! Concretely, restaurants will open in days, while restaurant will be opened on day and will be located at . The town should be imagined as an one dimensional line in which every object's location can be described by the coordinate. Tim has just recently arrived the town after a very bad result in a programming contest. Thus he wants to cheer himself up by starting a trip to try out some new burgers. Every burger restaurant is associ
View Solution →Sum of the Maximums
Alexey is playing with an array, , of integers. His friend, Ivan, asks him to calculate the sum of the maximum values for all subsegments of . More formally, he wants Alexey to find . Alexey solved Ivan's challenge faster than expected, so Ivan decides to add another layer of difficulty by having Alexey answer queries. The query contains subsegment , and he must calculate the sum of maximum values on all subsegments inside subsegment . More formally, for each query , Alexey must calcula
View Solution →