首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

hdu4237 The Rascal Triangle 法令题

2012-07-30 
hdu4237 The Rascal Triangle 规律题The Rascal TriangleTime Limit: 2000/1000 MS (Java/Others)Memory L

hdu4237 The Rascal Triangle 规律题

The Rascal TriangleTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 64    Accepted Submission(s): 61


Problem Description
Write a program which computes R(n,m) thehdu4237 The Rascal Triangle 法令题element of thehdu4237 The Rascal Triangle 法令题row of the Rascal Triangle.
InputOutputFor 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  输出5
1 4 0
2 4 2
3 45678 12345
4 12345 9876
5 34567 11398 题意R(n+1, m+1) = (R(n,m) * R(n,m+1) + 1)/R(n-1,m)R(n,0) = R(n,n) = 1数塔从第0层开始  每层也是从0 开始根据上面的2个式子推出来所有的问输入 a b  输出第a行第b个数字     0                                        1    1                                     1     1    2                                  1     2       1    3                               1     3     3        1    4                            1     4     5       4        1    5                        1      5     7     7        5        1    6                    1      6      9     10      9        6      1   可以看出第i行第j个满足 (i-j)*j+1;规律找了好久 最终还是看人家的  看着我的队友10几分钟就看出来了 我真的感到好丢人啊哎 只有努力了   抓紧时间搞下规律题#include<stdio.h>
int main()
{
 int a,i,j,T,k;
 scanf("%d",&T);
 while(T--)
 {
  scanf("%d %d %d",&a,&i,&j);
  if(i==j||j==0)
   printf("%d %d\n",a,1);
        else 
        {            
   k= (i-j)*j+1;          
   printf("%d %d\n", a, k); 
        } 
    } 
    return 0; 

热点排行