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

建议使用的浏览器:

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

4237:The Rascal Triangle

题目描述
The Rascal Triangle definition is similar to that of the Pascal Triangle. The rows are numbered from the top starting with 0. Each row n contains n+1 numbers indexed from 0 to n. Using R(n,m) to indicte the index m item in the index n row:
  
R(n,m) = 0 for n < 0 OR m < 0 OR m > n

The first and last numbers in each row(which are the same in the top row) are 1:
  
R(n,0) = R(n,n) = 1

The interior values are determined by (UpLeftEntry*UpRightEntry+1)/UpEntry(see the parallelogram in the array below):
  
R(n+1, m+1) = (R(n,m) * R(n,m+1) + 1)/R(n-1,m)


Write a program which computes R(n,m) theelement of therow of the Rascal Triangle.
输入解释
The first line of input contains a single integer P, (1 <= P <= 1000), which is the number of data sets that follow. Each data set is a single line of input consisting of 3 space separated decimal integers. The first integer is data set number, N. The second integer is row number n, and the third integer is the index m within the row of the entry for which you are to find R(n,m) the Rascal Triangle entry (0 <= m <= n <= 50,000).
输出解释
For each data set there is onr line of output. It contains the data set number, N, followed by a single space which is then followed by thr Rascal Triangle entry R(n,m) accurate to the integer value.
输入样例
5
1 4 0
2 4 2
3 45678 12345
4 12345 9876
5 34567 11398
输出样例
1 1
2 5
3 411495886
4 24383845
5 264080263
来自杭电HDUOJ的附加信息
Recommend

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

源链接: HDU-4237

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

共提交 0

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