title-img


Divisibility

Two positive integers P and S are given. is decimal representation of integer . Lets define . For example, if : For each query you will be given two integers and that define a substring equal to . Your task is to calculate divisibility of given substring. Divisibility of given substring is equal to number of pairs such that: and is divisible by , assuming that is divisible by any other integer. Timelimits Timelimits for this challenge is given here Input Format Fi

View Solution →

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 →