Battle of Brains (BoB) is the yearly programming contest among students of the University of Dhaka. Only first and second year students of DU (any department or institute) can take part in the contest. The sole purpose of this contest is to spark an interest in the realm of problem solving in the mind of the freshers and sophomores.
In CSEDU lab, there are two computers on each table. Two contestants may communicate if they are classmates and sit at the same table. But communication is not allowed between contestants since this is an individual contest. So the organizers planned not to seat two classmates at the same table. After all the contestants arrive, the volunteers are going to seat two contestants from two different years at each table. An interesting fact is that every year the number of first-year contestants is larger than the number of second-year contestants. So after a while, some contestants are still standing there and all are first-year students.
The volunteers count the total number of contestants and the number of first-year students who are still standing there.
Now you will be given the total number of contestants and the number of first-year contestants who are still standing there. Your task is to find the number of contestants from first-year and the number of contestants from second-year.
It is guaranteed that the given data is valid according to the aforementioned scenario.
The first line contains a single integer $$$ t \space ( 1 \le t \le 100 ) $$$ denoting the number of test cases.
The only line of each test case contains two integers $$$ a $$$ and $$$ b $$$ $$$ ( 1 \le b \lt a \lt 10^9) $$$ describing the total number of contestants and the number of first-year students who are still standing there.
For each test case print a single line containing two integers separated by a space describing the number of first-year contestants and the number of second-year contestants.
212 215 3
7 5 9 6
In the first sample, there are $$$7$$$ first year students and $$$5$$$ second year students. One can see that this is correct because the total number of students is $$$12$$$ and there will be exactly $$$2$$$ first year students still standing because $$$5$$$ of them will be paired with $$$5$$$ second year students.
You are given an array $$$A$$$ of $$$n$$$ integers, where the $$$i$$$-th element is $$$A_i$$$. You can choose exactly one $$$i$$$ such that $$$1 \leq i \leq n$$$ and change $$$A_i$$$ to $$$-A_i$$$ (in other words, you change the sign of $$$A_i$$$). You want to make the sum of the array even. In how many ways can you do this?
The first line contains an integer $$$T(1 \leq T \leq 100)$$$, the number of test cases.
For each test case, there are two lines. On the first line you are given $$$n\space(1 \leq n \leq 100)$$$, the number of integers in the array. The next line contains $$$n$$$ space-separated integers $$$A_1, A_2, ... , A_n\space(-100 \leq A_i \leq 100) $$$ denoting the array $$$A$$$.
For each test case, print one integer in seperate lines denoting the number of ways you can make the sum of the array even.
2 2 0 0 6 2 3 5 -2 -3 0
2 0
In the first sample, there are two $$$0$$$s. You can change the sign of either of them (it remains $$$0$$$). So the sum is always $$$0$$$, which is even. So there are $$$2$$$ ways to make the sum even.
In the second sample, you can verify that no matter which element you change the sign of, the sum is not even. So there are $$$0$$$ ways.
Given an integer $$$X$$$, let $$$f(X)$$$ denote the number of ordered pairs $$$(a,b)$$$ such that $$$\gcd(a,b) \times \text{lcm}(a,b) = X$$$.
A number $$$Y$$$ is beautiful if $$$f(Y)$$$ is odd.
Count the number of beautiful numbers that lie in a given range $$$[L, R]$$$.
Refer to the notes below if you don't understand some of these terms.
Input starts with an integer $$$T$$$ ($$$1 \leq T \leq 10$$$), denoting the number of test cases.
Each case starts with a line containing two integers $$$L$$$ and $$$R$$$ ($$$1 \le L \le R \le 10^9$$$).
For each query, you have to print a line containing the number of beautiful numbers in the range $$$[L,R]$$$.
2 2 8 4669 176420
1 352
The first three beautiful numbers are $$$1,4,9$$$.
In the first sample, the only beautiful number which lies between $$$2$$$ and $$$8$$$ is the number $$$4$$$. It is a beautiful number because there are $$$3$$$ ordered pairs $$$(a,b)$$$ satisfying the equation given in the statement: they are $$$(1,4),(2,2),(4,1)$$$. Since this number $$$3$$$ is odd, the number $$$4$$$ qualifies as beautiful. One can check that the other numbers between $$$2$$$ and $$$8$$$ do not satisfy these conditions.
Definitions
Alice and Bob went on an adventure, where they found a mysterious array $$$A$$$ consisting of $$$N$$$ positive integers. The $$$i$$$-th element of the array is called $$$A_i$$$.
Alice and Bob decided to play a game with this array, where each player moves in turn, and whoever can't find a valid move loses. Alice goes first. In simple words, Alice makes her move, then it is Bob's move, then it is Alice's move again, and so on. In every move, the player (whose move it is) does the following things sequentially:
The first line contains a positive integer representing the number of test cases.
For each test case, the first line contains a positive integer $$$N$$$ and the following line contains $$$N$$$ space-separated positive integers representing the array $$$A$$$.
Constraints
For each test case, print "Alice" or "Bob" in a single line without the quotes referring to who will win the game.
2 4 2 3 2 1 5 727 86197 46727 43969 34157
Bob Alice
In the first sample test case:
Jubayer is a nice and talented kid. He is a two times ICPC World Finalist. He used to utilize his time solving problems after problems. But after all those years of hard work and achievements, he decides to enjoy a tiny break from his daily routine and roam to the villages of his very own B.Baria district. So, he went to B.Baria. But he soon became very fed up as he saw he cannot go to every village in his district as there are not enough roads that can help him reach every village. Also, a weird pattern was caught to the attention of this great programmer. In his district, there are $$$n-1$$$ villages. The villages are named with natural numbers (don't ask me why, I am just a simple problem setter). For some weird reason, there is no village numbered as $$$1$$$. Villages are named from $$$2$$$ to $$$n$$$ (for example: if $$$n=5$$$ then name of the villages are $$$2$$$, $$$3$$$, $$$4$$$ and $$$5$$$). And there is a road connecting the village $$$i$$$ and the village $$$j$$$ if and only if either $$$i$$$ is divisible by $$$j$$$, or $$$j$$$ is divisible by $$$i$$$.
Now, Jubayer wishes to create some new roads to extend the reachability: he wants to connect every village and roam everywhere without any hassle. But he is failing to determine the minimum number of roads that he needs to construct in order to fulfill this purpose. Now it is your turn to help this world famous programmer.
First line will be number of test cases, $$$T\space(1 \le T \le 10^5)$$$.
Next $$$T$$$ lines will have a number $$$n\space(2 \le n \le 10^7)$$$ denoting the name of the last village in the district.
For each test case, print the minimum number of roads needed to connect all the villages in a single line.
2 2 5
0 2
Use faster input/output.
Explanation of the second test case: Here $$$n = 5$$$, so the villages are named $$$2,3,4,5$$$. There's already an edge between $$$2$$$ and $$$4$$$ because $$$2$$$ divides $$$4$$$.
You have to construct at least $$$2$$$ roads to make every village reachable to every other (via some roads).
The FIFA World Cup 2022 will take place in Qatar. The organizers plan to provide a prize to random attendees at the opening game. So they chose two integers $$$a$$$ and $$$b$$$. The integer $$$a$$$ represents bitwise $$$\textbf{OR}$$$ of a set of seat numbers and $$$b$$$ represents bitwise $$$\textbf{XOR}$$$ of the same set of seat numbers. The attendees assigned to those seats will receive the prizes. The organizers want to award prizes to as many people as possible. They therefore recruited you to identify the maximum possible number of attendees who are qualified for the award as well as their seat numbers. Each seat has a unique seat number, which is a non-negative integer.
See the notes if you forgot what bitwise $$$\textbf{OR}$$$ and $$$\textbf{XOR}$$$ means.
Each test consists of multiple test cases. The first line contains a single integer $$$T\space(1 \leq T \leq 100) $$$ — the number of test cases.
For each testcase, there will be two numbers representing $$$a$$$ and $$$b$$$ $$$(0 \leq a, b \leq 10^4)$$$.
For each testcase, if there is no solution, print $$$\textbf{-1}$$$.
Otherwise, print two lines.
3 5 1 11 2 11 4
3 0 4 5 7 0 1 3 8 9 10 11 -1
Consider the first sample test. One can verify that the bitwise OR of the numbers $$$[0,4,5]$$$ is $$$5$$$, and the bitwise XOR of the numbers $$$[0,4,5]$$$ is $$$1$$$. One can verify that there's no set of (distinct) numbers with a bigger size that satisfies these conditions.
Bitwise XOR: The bitwise XOR of non-negative integers $$$A$$$ and $$$B$$$, denoted $$$A\oplus B$$$, is defined as follows:
Bitwise OR: The bitwise OR of non-negative integers $$$A$$$ and $$$B$$$, denoted $$$A\mid B$$$, is defined as follows:
At the beginning of the winter season in 2022, Ayon and Lagno received two colorful scarves as gifts from their mother. The scarves each have their own color patterns which can be described as a string of letters where each letter identifies as a unique color. Lagno was worried that her scarf would not match her brother's, but fortunately, she found a way to modify the colors on her own scarf.
Consider the color pattern of a scarf as a string consisting of lowercase English letters only. The pattern for Lagno's scarf is $$$S$$$ and Ayon's scarf is $$$T$$$. Both strings are of equal length $$$n$$$. For a given integer $$$k$$$, you can perform the following operation as many times as you want (maybe zero).
Can Lagno change her string $$$S$$$ to make it equal to her brother's string $$$T$$$?
Input starts with an integer $$$T$$$ ($$$1\leq T\leq 10^6$$$), denoting the number of test cases.
Each case contains three lines. The first line contains two integers $$$n$$$ ($$$2 \leq n \leq 10^6$$$) and $$$k$$$ ($$$0 \lt k \lt n$$$). The following two lines contain Lagno's string $$$S$$$ and Ayon's string $$$T$$$. It is guaranteed that both strings have a length of $$$n$$$. The strings consist of lowercase English letters.
The sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$.
For each test case, print a single line containing "Yes" (without quotes) if string $$$S$$$ can be made equal to $$$T$$$ after zero or more operations, and "No" (without quotes) otherwise.
2 5 2 ebadc abcbc 12 1 aaabccabbdbb abaaaabdbbbc
Yes No
In the first sample, you can perform the following operations:
Alice and Bob are playing a game. Alice gives Bob an integer $$$k$$$. Then Bob picks another non-negative integer $$$n$$$ and performs some moves (possibly zero) on $$$n$$$. In one move, he does the following:
Input starts with an integer $$$T$$$ ($$$1\leq T\leq 10^5$$$), denoting the number of test cases.
Each of the next $$$T$$$ lines contain two integers $$$r$$$ ($$$0 \leq r \leq 10^{18}$$$) and $$$k$$$ ($$$2 \leq k \leq 10^{18}$$$).
For each test case, you have to print the maximum number of moves that can be performed among all $$$n$$$, such that $$$0 \leq n \leq r$$$.
2 5 2 4 3
4 3
In the first sample, we have $$$r=5$$$. So $$$n$$$ cannot be bigger than $$$5$$$.
If we choose $$$n = 5$$$, we get the maximum number of moves $$$=4$$$.
Alice and Bob found a divine stairway when they went on an adventure to the seventh sky. As always, they decided to play a game with it. The rules of the game are following:
The only line contains two positive integers $$$u$$$ and $$$v$$$ ($$$ 2 \le u \lt v\le 10^5$$$) denoting the label of hell and heaven respectively.
Print the number of different ways Bob can reach heaven from hell in a single line. The answer might be very big. So print the answer modulo $$$998244353$$$.
2 5
3
69 69420
81268163
For the sample test, the following $$$3$$$ paths are valid:
Given a sorted array $$$A$$$ with $$$N$$$ elements (non-decreasing order), you will be given $$$Q$$$ queries. In each query, you will be given a range $$$[L, R]$$$. For each query, you have to find the number of non-negative integers $$$X$$$ such that $$$X \lt 2^{20}$$$ and after doing the following operation the whole array remains sorted (non-decreasing order):
Note that the queries are independent. So you do not actually apply the operations on the array when you move on to the next query.
Input starts with an integer $$$T\space(1 \le T \le 10^5)$$$, denoting the number of test cases.
Each case starts with an integer $$$N\space(1 \le N \le 10^5)$$$, denoting the number of elements in the array $$$A$$$. The next line will contain $$$N$$$ integers $$$A_1,A_2, ...., A_N\space(1 \le A_i \lt 2^{20})$$$ separated by spaces which denote the elements of the array.
The next line contains an integer $$$Q\space(1 \le Q \le 10^5)$$$ which denotes the number of queries. Each of the next $$$Q$$$ lines contains two space separated integer denoting $$$L$$$ and $$$R\space(1 \le L \le R \le N)$$$.
Additional constraint on the input:
For each query, you have to print a line containing the number of such $$$X$$$.
1 4 1 4 5 5 3 1 2 2 3 1 4
2 2 262144