zoukankan      html  css  js  c++  java
  • AOJ 763.过河卒

    过河卒
    Time Limit: 1000 ms   Case Time Limit: 1000 ms   Memory Limit: 64 MB
    Total Submission: 23   Submission Accepted: 5
     
    Description
    在一个n*m的矩阵上,A点有一个过河卒,需要走到目标B点。卒行走的规则:只能向下或者向右。每一步能水平或者垂直移动一个点(纵横线的交叉点)的距离。计算从A 点能够到达B点的路径的条数。
    设行、列数为m和n, 2<=m,n<=20
    Input
    只有一行,包含4个整数,即B点坐标(x1,y1) 和 A点坐标(x2,y2),
    保证A,B在地图内。
    Output
    一个整数,为路径的条数,答案对1000000007取模
    Sample Input
    Original Transformed
    6  6  3  2
    Sample Output
    Original Transformed
    35
    Hint
    可能走不到

    递推(dp)或者组合数

    最后答案记得取模

    AC代码:GitHub

     1 /*
     2 By:OhYee
     3 Github:OhYee
     4 HomePage:http://www.oyohyee.com
     5 Email:oyohyee@oyohyee.com
     6 Blog:http://www.cnblogs.com/ohyee/
     7  
     8 かしこいかわいい?
     9 エリーチカ!
    10 要写出来Хорошо的代码哦~
    11 */
    12  
    13 #include <cstdio>
    14 #include <algorithm>
    15 #include <cstring>
    16 #include <cmath>
    17 #include <string>
    18 #include <iostream>
    19 #include <vector>
    20 #include <list>
    21 #include <queue>
    22 #include <stack>
    23 #include <map>
    24 using namespace std;
    25  
    26 //DEBUG MODE
    27 #define debug 0
    28  
    29 //循环
    30 #define REP(n) for(int o=0;o<n;o++)
    31  
    32 //初始化
    33 #define mst(a,n) memset(a,n,sizeof(a))
    34  
    35 int Map[25][25];
    36 const int MOD = 1000000007;
    37  
    38 bool Do() {
    39     int x1,y1,x2,y2;
    40     if(scanf("%d%d%d%d",&x1,&y1,&x2,&y2) == EOF)
    41         return false;
    42  
    43     mst(Map,0);
    44  
    45     Map[x2][y2] = 1;
    46     for(int i = x2;i <= x1;i++)
    47         for(int j = y2;j <= y1;j++)
    48             if(!(i == x2&&j == y2))
    49                 Map[i][j] = (Map[i][j - 1] + Map[i - 1][j]) % MOD;
    50     printf("%d
    ",Map[x1][y1]);
    51     return true;
    52 }
    53  
    54 int main() {
    55     while(Do());
    56     return 0;
    57 }
  • 相关阅读:
    1-1圆柱体的表面积
    vue的重定向和404
    新特性
    vue的一些概念
    关于ES6包的导出和导入
    vue-父组件和子组件的交互
    vue-组件
    vue---指令
    angular基础--指令2
    angular基础
  • 原文地址:https://www.cnblogs.com/ohyee/p/5513869.html
Copyright © 2011-2022 走看看