Problem
国王奇遇记加强版之再加强版
Description
Input
共一行,包括两个正整数和。
Output
共一行,为所求表达式的值对取模的值。
有两个好朋友,他们叫宁宁和冉冉。
有一天,冉冉遇到了一个有趣的题目:输入,求
一行三个整数。
一行一个数表示模之后的结果。
Snuke has decided to play with cards and a deque (that is, a double-ended queue). Each card shows an integer from through , and the deque is initially empty.
Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from to . Then, he will perform the following action times: take out the card from the beginning or the end of the deque and eat it.
Afterwards, we will construct an integer sequence by arranging the integers written on the eaten cards, in the order they are eaten. Among the sequences that can be obtained in this way, find the number of the sequences such that the element is . Print the answer modulo .
The input is given from Standard Input in the following format:
Print the answer modulo .
by Birjik
Birzhan has cards, numbered from to . Every card has each number from to written on it. Some numbers exist on the front side of the card and some on the back side. No number exists on both the sides of a card at the same time. These cards are placed on the table in a row such that only one side is visible. Birzhan is allowed to flip them any number of times.
Now, Birzhan has to answer queries each of them consisting of two integers and (). We define as the sum of the squares of every integer from to if it exists on the visible side of any card numbered from to . Given that Birzhan can flip any number of cards any number of times, find and print the maximum value of .
For example, given cards and we have the as follows:-
The first line contains three space-separated integers, , , and , denoting the number of cards, what numbers written on each card, and the number of queries, respectively.
Each of the next lines describes the cards. On each line, the first number is , denoting the count of numbers written on the visible side of the card. Next space-separated unique integers represent the numbers written on the visible side of that card, each between and .
Next lines contain two space-separated integers, and , describing the query mentioned above.
Print the maximum value of for each query.
是一个拥有诸多城市的大国,国王为城市的交通建设可谓绞尽脑汁。可以在某些城市之间修建道路,在不同的城市之间修建道路需要不同的花费。希望建造最少的道路使得国内所有的城市连通。但是由于某些因素,城市之间修建道路需要的花费会随着时间而改变,会不断得到某道路的修建代价改变的消息,他希望每得到一条消息后能立即知道使城市连通的最小花费总和,决定求助于你来完成这个任务。
第一行三个整数,分别表示城市的数目,可以修建的道路个数,收到的消息个数。
接下来行,第行有三个用空格隔开的整数(),表示在城市与城市之间修建道路的代价为。
接下来行,每行包含两个数,表示输入的第个道路的修建代价修改为(即将修改为)。
行,第行输出得知前条消息后使城市连通的最小花费总和。
As it has been found out recently, all the Berland’s current economical state can be described using a simple table in size. ― the number of days in each Berland month, ― the number of months. Thus, a table cell corresponds to a day and a month of the Berland’s year. Each cell will contain either , or , which means the state’s gains in a particular month, on a particular day. corresponds to profits, corresponds to losses. It turned out important for successful development to analyze the data on the state of the economy of the previous year, however when the treasurers referred to the archives to retrieve the data, it turned out that the table had been substantially damaged. In some table cells the number values had faded and were impossible to be deciphered. It is known that the number of cells in which the data had been preserved is strictly less than . However, there is additional information ― the product of the numbers in each line and column equaled . Your task is to find out how many different tables may conform to the preserved data. As the answer to the task can be quite large, you have to find it modulo .
The first line contains integers and . The second line contains the integer ― the number of cells in which the data had been preserved. The next lines contain the data on the state of the table in the preserved cells. Each line is of the form a b c
, where ― the number of the table row, ― the number of the column, ― the value containing in the cell ( or ). They are numbered starting from . It is guaranteed that no two lines with same and values exist. The last line contains an integer .
Print the number of different tables that could conform to the preserved data modulo .
小苗去市场上买了一捆小葱苗,她突然一时兴起,于是她在每颗小葱苗上写上一个数字,然后把小葱叫过来玩游戏。
每个时刻她会给小葱一颗小葱苗或者是从小葱手里拿走一颗小葱苗,并且让小葱从自己手中的小葱苗里选出一些小葱苗使得选出的小葱苗上的数字的异或和最大。
这种小问题对于小葱来说当然不在话下,但是他的身边没有电脑,于是他打电话给同为选手的你,你能帮帮他吗?
你只需要输出最大的异或和即可,若小葱手中没有小葱苗则输出0
。
第一行一个正整数表示总时间。
第二行个整数,若大于代表给了小葱一颗数字为的小葱苗,否则代表从小葱手中拿走一颗数字为的小葱苗。
输出共行,每行一个整数代表第个时刻的最大异或和。