当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5223:GCD

题目描述
In mathematics, the greatest common divisor (gcd) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4.---Wikipedia

BrotherK and Ery like playing mathematic games. Today, they are playing a game with GCD.

BrotherK has an array $A$ with $N$ elements: $A_1$ ~ $A_N$, each element is a integer in [1, 10^9]. Ery has $Q$ questions, the i-th question is to calculate
GCD($A_{L_i},~A_{L_i + 1},~A_{L_i + 2},~...,~A_{R_i}$), and BrotherK will tell her the answer.

BrotherK feels tired after he has answered $Q$ questions, so Ery can only play with herself, but she don't know any elements in array $A$. Fortunately, Ery remembered all her questions and BrotherK's answer, now she wants to recovery the array $A$.
输入解释
The first line contains a single integer $T$, indicating the number of test cases.

Each test case begins with two integers $N,~Q$, indicating the number of array $A$, and the number of Ery's questions. Following $Q$ lines, each line contains three integers $L_i,~R_i$ and $Ans_i$, describing the question and BrotherK's answer.

$T$ is about 10

$2~\le~N~Q~\le~1000$

$1~\le~L_i~\lt~R_i~\le~N$

$1~\le~Ans_i~\le~10^9$
输出解释
For each test, print one line.

If Ery can't find any array satisfy all her question and BrotherK's answer, print "Stupid BrotherK!" (without quotation marks). Otherwise, print $N$ integer, i-th integer is $A_i$.

If there are many solutions, you should print the one with minimal sum of elements. If there are still many solutions, print any of them.
输入样例
2
2 2
1 2 1
1 2 2
2 1
1 2 2
输出样例
Stupid BrotherK!
2 2
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5223

最后修改于 2020-10-25T23:20:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)