Batch-24 is hosting a "Pre-IUT Meetup" at Smashed Burgers. As part of the registration process, the organizers created registration forms with unique form IDs starting from $$$1$$$ and increasing sequentially.
When registration ended, the organizers found that the number of submissions greatly exceeded the actual number of students in their batch. After the investigation, they discovered that impostors from other batches had also filled out the forms. They examined a few impostor entries and were relieved to find a pattern. An entry is made by an impostor if for the form ID $$$x$$$, $$$x^2 - 1 \text{ is divisible by 24} \quad \text{i.e.,} \quad (x^2 - 1) \equiv 0 \pmod{24}.$$$
Your task is to count the total number of impostors among the first $$$N$$$ form submissions to maintain the Glory of 24!
The first line of the input contains a single integer $$$T$$$ ($$$1 \leq T \leq 10^5$$$) — the number of test cases.
Each test case consists of a single line containing a single integer $$$N$$$ ($$$1 \leq N \leq 10^{18}$$$) — the total number of forms submitted.
For each test case, output a single integer in a line — the number of impostors.
41913456100000000
13448533333333
You are given the first $$$m$$$ elements of an infinite sequence $$$a_1, a_2, \ldots, a_m$$$.
For every index $$$i \gt m$$$, the sequence is extended according to the following rule: $$$$$$ a_i = a_{i-2} \oplus a_{i-1}, $$$$$$ where $$$\oplus$$$ denotes the bitwise XOR operation.
Your task is to determine the value of $$$a_1 \oplus a_2 \oplus \cdots \oplus a_n$$$, that is, the bitwise XOR of the first $$$n$$$ elements of the sequence.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains two space-separated integers $$$n$$$ and $$$m$$$ ($$$2 \le m \le n$$$, $$$m \le 2 \times 10^5$$$, $$$n \le 10^9$$$).
The second line of each test case contains $$$m$$$ space-separated integers $$$a_1, a_2, \ldots, a_m$$$ ($$$0 \le a_i \lt 2^{30}$$$) — the first $$$m$$$ elements of the sequence.
It is guaranteed that the sum $$$m$$$ over all test cases does not exceed $$$2 \times 10^5$$$.
For each test case, output a single integer in a line – the bitwise XOR of the first $$$n$$$ elements of the sequence.
35 41 2 3 48 33 5 14100 20 0
360
In the first test case, $$$a_5 = a_4 \oplus a_3 = 4 \oplus 3 = 7$$$. So, the bitwise XOR of the first $$$5$$$ elements of the sequence is $$$1 \oplus 2 \oplus 3 \oplus 4 \oplus 7 = 3$$$.
In the third test case, all the elements in the sequence are $$$0$$$, and so the bitwise XOR of the first $$$100$$$ elements is also $$$0$$$.
Zunaid is notoriously forgetful. To make his life easier, he always sets his computer password using a combination of his favorite digits: $$$0$$$ and $$$d$$$. He usually sticks to predictable, simple patterns—like a sequence of $$$d$$$s followed by some $$$0$$$s (e.g., $$$dddd0000$$$), or simple repeating arrangements that his forgetful mind can easily retrace (e.g., $$$dd00dd$$$ or $$$d0d0d0$$$).
His roommate, Imtiaz, considers himself a bit of a detective. He has spent months "studying" Zunaid's habits and has successfully cracked the password dozens of times. On a particularly chilly winter night, Zunaid decided he'd had enough. He set a new password, stood by the door, and smirked at Imtiaz.
"I'm heading over to CDS for a bit. I've set a password so strong that you can never deduce it. If you can crack it before I return, I'll treat you to an IUTian's Pizza tomorrow. If not, you owe me."
The inner detective in Imtiaz couldn't refuse. As soon as the door clicked shut, he pulled out a cheap UV flashlight. Shining it over the keypad, he saw deep, glowing marks only on the $$$0$$$ and $$$d$$$ keys, just as he had suspected. He noticed a hint on the lock screen: "Divisible by $$$n$$$." He also knew a password could consist of at most $$$n$$$ digits.
Luck wasn't on Imtiaz's side. Zunaid returned much earlier than expected. However, Imtiaz confidently claimed he had already deduced the password's logic and surely could have cracked it if he had been given five more minutes. Hearing his deductions, Zunaid laughed and replied, "Deducing the properties was the easy part! I'll still buy the pizza if you can actually give me any positive integer that follows the properties:"
Time is running out. Can you help Imtiaz get the free pizza?
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases.
Each test case consists of a single line containing two integers $$$n$$$ and $$$d$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le d \le 9$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. For each test case, it is guaranteed that at least one such positive integer exists.
For each test case, output a positive integer in a line that consists only of the digits $$$0$$$ and $$$d$$$, is divisible by $$$n$$$, contains no leading zero and has a length that does not exceed $$$n$$$.
If there are multiple solutions, you may output any of them.
36 49 36 3
4440 333333333 303330
In the first test case, $$$n = 6$$$ and $$$d = 4$$$. The output $$$4440$$$ is a positive integer of length $$$4 \le 6$$$. It consists only of $$$4$$$ and $$$0$$$, and it is divisible by $$$6$$$.
In the second test case, $$$n = 9$$$ and $$$d = 3$$$. The output $$$333333333$$$ consists only of the digit $$$3$$$. Its length is $$$9 \le 9$$$, and it is divisible by $$$9$$$.
In the third test case, $$$n = 6$$$ and $$$d = 3$$$. The output $$$303330$$$ is a positive integer of length $$$6 \le 6$$$. It consists only of $$$3$$$ and $$$0$$$, and is divisible by $$$6$$$.
There are $$$N$$$ players participating in a game involving a glass bridge. The bridge consists of $$$M$$$ steps, and each step has two glass panels: one is safe, and the other is fragile and will break if stepped upon.
The players cross the bridge one at a time, following their position in a queue from $$$1$$$ to $$$N$$$. The rules are as follows:
Every player is rational and will use all information revealed by previous players. If a player reaches a step where the safe panel is unknown, they will choose one of the two panels with a $$$50\%$$$ probability of success.
You have the chance to bribe the organizers to pick any starting position from $$$1$$$ to $$$N$$$. Your goal is to choose the position $$$k$$$ that maximizes your probability of being the sole winner. If multiple positions yield the same maximum probability, choose any such $$$k$$$.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of test cases.
Each test case consists of a single line containing two integers:
For each test case, output a single integer — the optimal position $$$k$$$ ($$$1 \le k \le N$$$) to maximize your winning probability.
31 12 23 3
123
The following diagram illustrates the glass bridge for the second test case:
For the second test case, if you start at position $$$1$$$ in the queue, then you must correctly choose the safe panel on both steps. Since each unknown step has a success probability of $$$1/2$$$, your probability of winning is:
$$$$$$ \frac{1}{2} \times \frac{1}{2} = \frac{1}{4} = 25\%. $$$$$$
However, if you start at position $$$2$$$, there are two cases where you win:
Hence, the total probability of winning when starting at position $$$2$$$ is:
$$$$$$ \frac{1}{4} + \frac{1}{4} = \frac{1}{2} = 50\%. $$$$$$
It was the first AutoCAD lab for the first-year students at Irony University of Technology.
Labib and his friend Jehad were sitting side by side. The lab task was simple: draw a triangle using the given line measurements. Excited to finish the task quickly, they were racing each other instead of listening to the instructor.
Confident in their abilities, both of them ignored the tutorial completely and drew their own triangles much faster than the others.
A few minutes later, panic struck.
Neither of them remembered the actual measurements from the instructions, so they had no idea whether their drawings were correct. But instead of checking the lab sheet like normal students, they became curious about something much more interesting:
"By pure luck, did we draw similar triangles?!"
You are given the three side lengths of both triangles. Determine whether the two triangles are similar*.
*Two triangles with side lengths $$$(a, b, c)$$$ and $$$(d, e, f)$$$ are considered similar if there exists a permutation $$$(x, y, z)$$$ of $$$(d, e, f)$$$ such that
$$$$$$\displaystyle \dfrac{a}{x} = \dfrac{b}{y} = \dfrac{c}{z}$$$$$$
The input consists of a single line containing six space-separated integers $$$a, b, c, d, e, f$$$ ($$$1 \le a, b, c, d, e, f \le 10^9$$$) — $$$(a, b, c)$$$ are the side lengths of Labib's triangle and $$$(d, e, f)$$$ are the side lengths of Jehad's triangle.
Output "YES" if the triangles are similar, "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
2 3 4 4 6 8
YES
2 3 4 4 6 7
NO
While doing group projects together in their university life, Meena and Kabir used to dream of opening a vintage-style book-cafe. Years later, their dream is finally coming true. The heart of their cafe is a Shelf, holding $$$n$$$ of their favorite books.
Kabir has just finished unboxing the books into an initial order $$$a$$$. Each book is identified by an ID number; since they have several copies of certain favorites, multiple books may share the same ID.
As always, Meena suggests a game: they win if they can reach their "dream" arrangement $$$b$$$—the one from their university notebooks—by only swapping books that are exactly $$$m$$$ slots apart. Formally, they can choose an index $$$i \le n-m$$$, and swap the books at index $$$i$$$ and $$$i+m$$$. As they sip their coffee and enjoy the quiet atmosphere of their new cafe, they wonder if the IDs on the shelf will allow them to win their game.
The first line of input contains $$$t$$$ ($$$1 \le t \le 10^5$$$), the number of testcases.
The first line of each testcase contains two space-separated integers $$$n$$$ and $$$m$$$ ($$$1 \le m \lt n \le 10^5$$$).
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the IDs of the books in which Kabir unboxed them.
The third line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 10^9$$$) — the ordered IDs in the dream arrangement $$$b$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output "YES" if it is possible for them to win, "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
16 21 2 3 4 5 61 6 3 4 5 2
Yes
42 15 44 53 15 3 13 1 511 72 5 5 2 5 3 3 4 5 2 15 5 2 4 3 2 5 3 5 1 24 34 3 2 34 2 3 3
YesYesNoNo
In the only testcase of the first sample, selecting $$$i = 2$$$ for first operation, $$$i = 4$$$ for second, and $$$i = 2$$$ for third operation makes arrangement $$$a$$$ equal to arrangement $$$b$$$, thus the answer is "YES".
Moushi is a very serious competitive programmer. As ICPC is approaching, her coach assigns her a strict training rule: she must solve an even number of problems every day.
To stay on track, she writes down her target solve count for the next $$$T$$$ days $$$X_1, X_2, \dots, X_T$$$ and goes to sleep.
However, she wakes up to find that the digit 9 has completely vanished from the world, making the number system consisting only of digits $$$0$$$ to $$$8$$$. Because of this change, she can no longer decide whether a number is even or odd by simply checking its last digit.
To ensure that her target of the day complies with the coach's requirement, Moushi needs to re-evaluate all the numbers under this new base-$$$9$$$ numeral system.
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^3$$$) — the number of days.
The $$$i$$$-th of the next $$$T$$$ lines contains two space-separated integers $$$n_i$$$ and $$$X_i$$$ ($$$1 \le n_i \le 10^5$$$), where $$$n_i$$$ is the number of digits in $$$X_i$$$, and $$$X_i$$$ is the number of problems (in base-$$$9$$$) Moushi needs to solve on day $$$i$$$.
It is guaranteed that $$$X_i$$$ does not contain leading zeros.
It is also guaranteed that the sum of $$$n_i$$$ over all days does not exceed $$$10^5$$$.
For each day, output "YES" if the goal for that day is valid, "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
51 84 12345 1234532 1234567812345678123456781234567820 12345671234567123456
YESYESNOYESNO
Tariq needs to solve the following math problem for his homework:
He decided to consult with ChatGPT for help.
Figure: Conversation with ChatGPT. May 20, 2026, 10:07 AM. However, Tariq does not fully trust ChatGPT's answer, so he came to you. Can you provide the correct answer?
This problem has no input.
Output one single integer — the number of apples.
Denji and Reze went to explore a school building at night. The building has $$$4$$$ rooms arranged in a $$$2 \times 2$$$ grid. Each room contains a light bulb, but the electrical system is malfunctioning.
Each room has a switch, but the switches are broken. Pressing the switch in a room does not affect the light in that room. Instead, it toggles the lights in the two adjacent rooms, namely the rooms directly above, below, to the left, or to the right. Toggling a light means changing its state from ON to OFF, or OFF to ON.
Reze asked Denji to turn all the lights OFF. Denji can press any switch any number of times and in any order. Given the initial state of the lights, determine whether it is possible for him to turn all the lights OFF at the same time.
The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases.
Each test case consists of two lines, each containing exactly two characters. These two lines represent the two rows of the $$$2 \times 2$$$ grid of rooms. For each character, a value of 0 means that the light in the corresponding room is initially OFF, and a value of 1 means that the light in the corresponding room is initially ON.
For each test case, output "YES" if it is possible to turn all the lights OFF at the same time, "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
40000111101001001
YESYESNOYES
In the first test case, all the lights are already OFF.
The following is the illustration of the second test case. The blue highlight indicates the next switch to be pressed.
It can be proven that it is not possible to turn all the lights OFF at the same time in the third test case.
The New World is a chaotic sea, but even the most notorious pirate crews have a rhythm to their madness. "Big News" Morgans, president of the World Economy News Paper, has discovered that every pirate crew follows a bizarre, endlessly repeating cycle of daily activities. He is utilizing this predictability to track their movements, anticipate clashes, and write his next front-page headline.
There are $$$K$$$ pirate crews currently being tracked. Each crew $$$i$$$ enters the New World on a specific starting date and follows an infinitely repeating activity cycle represented by a string $$$P_i$$$. The string consists of the characters S (Sailing), F (Fighting), P (Partying), and D (Docked).
For example, if a crew's pattern is SFFD, they will spend their first active day sailing, the next two days fighting, the fourth day docked, and on the fifth day, the cycle restarts with sailing. A crew is considered strictly inactive on any date prior to their starting date.
Morgans has a series of $$$Q$$$ queries to track the fleets. You must process three types of queries:
The first line contains a single integer $$$K$$$ ($$$1 \le K \le 50$$$) — the number of pirate crews.
The following $$$K$$$ lines describe the crews. The $$$i$$$-th line contains three space-separated strings:
The next line contains a single integer $$$Q$$$ ($$$1 \le Q \le 5000$$$) — the number of queries.
The following $$$Q$$$ lines each contain a space-separated query in one of the following formats:
All dates in the input are guaranteed to be valid and fall within the range 01/01/2000 to 31/12/2050 inclusive. Additionally, for Type 3 queries, it is guaranteed that the entire $$$69$$$-day window (the given date and the $$$68$$$ days following it) will strictly fall on or before 31/12/2050.
For each query, output the answer on a new line:
4STRAWHAT 28/02/2024 SFFHEART 01/03/2024 FDDKID 01/03/2024 SFPBUGGY 01/01/2024 P61 01/03/2024 F1 29/02/2024 D2 STRAWHAT 02 20242 HEART 02 20243 STRAWHAT HEART 28/02/20243 BUGGY KID 01/01/2024
HEART STRAWHAT NONE 1 1 0 0 0 0 01/03/2024 PEACE
Explanation of the test case
The year 2024 is a leap year, meaning February has 29 days.
In an advanced material science lab, researchers are studying the crystal structure of alkali metals, such as sodium and potassium. These metals form a body-centered cubic (BCC) lattice, which is a repeating three-dimensional arrangement of atoms.
In a BCC lattice, each unit cell consists of one atom at the center of the cube and eight atoms at the corners of the cube. Each corner atom is shared by eight adjacent unit cells.
The domain of an atom is the region where its force strength is stronger than that of any other atom. In other words, the domain of an atom is the set of points that are closer to that atom than any other atom.
Your task is to calculate the volume of the domain of a center atom of a BCC lattice given its lattice spacing (side length of the unit cells) as a fraction $$$\dfrac{p}{q}$$$.
The first line of the input contains an integer $$$t \: (1 \leq t \leq 100)$$$ — the number of test cases.
Each test case consists of a single line containing two space-separated integers $$$p$$$ and $$$q \:(1 \leq p, q \leq 100)$$$ — the numerator and the denominator of the fraction representing the lattice spacing.
For each test case, output a single number in a line — the volume of the domain of a center atom.
The answer will be considered correct if the absolute error does not exceed $$$10^{-6}$$$.
27 315 4
6.351852 26.367188
The domain of the center atom in a unit cell is illustrated in the following figure: