text
stringlengths 0
801
|
---|
The only line of each test case contains a single integer $x$ ($10 \leq x \leq 10^{18}$). |
For each test case, output $\texttt{YES}$ if $x$ satisfies the condition, and $\texttt{NO}$ otherwise. |
You can output $\texttt{YES}$ and $\texttt{NO}$ in any case (for example, strings $\texttt{yES}$, $\texttt{yes}$, and $\texttt{Yes}$ will be recognized as a positive response). |
In the first test case, we can have $658 + 679 = 1337$. |
In the second test case, it can be shown that no numbers of equal length and only consisting of large digits can add to $200$. |
In the third test case, we can have $696\,969 + 696\,969 = 1\,393\,938$. |
In the fourth test case, we can have $777 + 657 = 1434$. |
A contest contains $n$ problems and the difficulty of the $i$-th problem is expected to be at most $b_i$. There are already $n$ problem proposals and the difficulty of the $i$-th problem is $a_i$. Initially, both $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$ are sorted in non-decreasing order. |
Some of the problems may be more difficult than expected, so the writers must propose more problems. When a new problem with difficulty $w$ is proposed, the most difficult problem will be deleted from the contest, and the problems will be sorted in a way that the difficulties are non-decreasing. |
In other words, in each operation, you choose an integer $w$, insert it into the array $a$, sort array $a$ in non-decreasing order, and remove the last element from it. |
Find the minimum number of new problems to make $a_i\le b_i$ for all $i$. |
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le 100$). The description of the test cases follows. |
The first line of each test case contains only one positive integer $n$ ($1 \leq n \leq 100$), representing the number of problems. |
The second line of each test case contains an array $a$ of length $n$ ($1\le a_1\le a_2\le\cdots\le a_n\le 10^9$). |
The third line of each test case contains an array $b$ of length $n$ ($1\le b_1\le b_2\le\cdots\le b_n\le 10^9$). |
For each test case, print an integer as your answer in a new line. |
In the first test case: |
* Propose a problem with difficulty $w=800$ and $a$ becomes $[800,1000,1400,2000,2000,2200]$. * Propose a problem with difficulty $w=1800$ and $a$ becomes $[800,1000,1400,1800,2000,2000]$. |
It can be proved that it's impossible to reach the goal by proposing fewer new problems. |
In the second test case: |
* Propose a problem with difficulty $w=1$ and $a$ becomes $[1,4,5,6,7,8]$. * Propose a problem with difficulty $w=2$ and $a$ becomes $[1,2,4,5,6,7]$. * Propose a problem with difficulty $w=3$ and $a$ becomes $[1,2,3,4,5,6]$. |
It can be proved that it's impossible to re |
The two versions of the problem are different. You may want to read both versions. You can make hacks only if both versions are solved. |
You are given an array $a$ of length $n$. Start with $c = 0$. Then, for each $i$ from $1$ to $n$ (in increasing order) do exactly one of the following: |
* Option $1$: set $c$ to $c + a_i$. * Option $2$: set $c$ to $|c + a_i|$, where $|x|$ is the absolute value of $x$. |
Let the maximum final value of $c$ after the procedure described above be equal to $k$. Find the number of unique procedures that result in $c = k$. Two procedures are different if at any index $i$, one procedure chose option $1$ and another chose option $2$, even if the value of $c$ is equal for both procedures after that turn. |
Since the answer may be large, output it modulo $998\,244\,353$. |
The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. |
The first line of each test case contains a single integer $n$ ($2 \leq n \leq 2 \cdot 10^5$). |
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($-10^9 \leq a_i \leq 10^9$). |
The sum of $n$ over all test cases does not exceed $3 \cdot 10^5$. |
For each test case, output a single integer — the number of unique procedures that result in $c = k$, modulo $998\,244\,353$. |
In the first test case, it can be shown that our maximal final value of $c$ is $3$. There are $12$ ways to achieve this because in order to get $3$, we have to take absolute value at indices $2$ or $4$, or both, resulting in $3$ ways. For the other two indices, it doesn't change the value whether we take absolute value or not, so we have $2 \cdot 2 = 4$ ways for them. In total, we have $3 \cdot 4 = 12$ ways. |
In the second test case, taking the absolute value will never change anything, so we can either take absolute value or not, for every index. This gives us $2^8 = 256$ possible ways. |
You are given a string $s$ consisting of lowercase Latin characters. Count the number of nonempty strings $t \neq$ "$\texttt{a}$" such that it is possible to partition$^{\dagger}$ $s$ into some substrings satisfying the following conditions: |
* each substring either equals $t$ or "$\texttt{a}$", and * at least one substring equals $t$. |
$^{\dagger}$ A partition of a string $s$ is an ordered sequence of some $k$ strings $t_1, t_2, \ldots, t_k$ (called substrings) such that $t_1 + t_2 + \ldots + t_k = s$, where $+$ represents the concatenation operation. |
The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. |
The only line of each test case contains a string $s$ consisting of lowercase Latin characters ($2 \leq |s| \leq 2 \cdot 10^5$). |
The sum of $|s|$ over all test cases does not exceed $3 \cdot 10^5$. |
For each test case, output a single integer — the number of nonempty strings $t \neq$ "$\texttt{a}$" that satisfy all constraints. |
In the first test case, $t$ can be "$\texttt{aa}$", "$\texttt{aaa}$", "$\texttt{aaaa}$", or the full string. |
In the second test case, $t$ can be "$\texttt{b}$", "$\texttt{bab}$", "$\texttt{ba}$", or the full string. |
In the third test case, the only such $t$ is the full string. |
Two hungry red pandas, Oscar and Lura, have a tree $T$ with $n$ nodes. They are willing to perform the following shuffle procedure on the whole tree $T$ exactly once. With this shuffle procedure, they will create a new tree out of the nodes of the old tree. |
1. Choose any node $V$ from the original tree $T$. Create a new tree $T_2$, with $V$ as the root. 2. Remove $V$ from $T$, such that the original tree is split into one or more subtrees (or zero subtrees, if $V$ is the only node in $T$). 3. Shuffle each subtree with the same procedure (again choosing any node as the root), then connect all shuffled subtrees' roots back to $V$ to finish constructing $T_2$. |
After this, Oscar and Lura are left with a new tree $T_2$. They can only eat leaves and are very hungry, so please find the maximum number of leaves over all trees that can be created in exactly one shuffle. |
Note that leaves are all nodes with degree $1$. Thus, the root may be considered as a leaf if it has only one child. |
The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. |
The first line of every test case contains a single integer $n$ ($2 \leq n \leq 2 \cdot 10^5$) — the number of nodes within the original tree $T$. |
The next $n - 1$ lines each contain two integers $u$ and $v$ ($1 \leq u, v \leq n$) — an edge within the original tree $T$. The given edges form a tree. |
The sum of $n$ over all test cases does not exceed $3 \cdot 10^5$. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.