书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

滚动数组的简单应用

题目:http://acm.swust.edu.cn/oj/problem/324/

View Code
//1.动态范围
//2.动态次数
//3.动态规律
//4.动态边界
#include <stdio.h>
#include<string.h>
int main()
{
    int Live, Stand, Step;
    int f[101][2];
    while(scanf("%d%d%d", &Live, &Step, &Stand)!=EOF){
        memset(f, 0, sizeof(f));
        f[Stand][0] = 1;
        int Roll = 1;
        for(int i=0; i<Step; i++){
            for(int j=1; j<100; j++){
                f[j][Roll] = f[j-1][1-Roll]+f[j+1][1-Roll];
            }
            f[100][Roll] = f[99][1-Roll];
            Roll = 1-Roll;
        }
        printf("%d\n", f[Live][1-Roll]);
    }
}

posted on 2012-05-09 23:47  More study needed.  阅读(161)  评论(0编辑  收藏  举报

导航

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!