• poj1942(Paths on a Grid)


    题目地址:Paths on a Grid

    题目大意:

        给你一个矩形的格子,让你从左下角走到右上角,每次移动只能向上或者向右,问你有多少种可能的路径。

    解题思路:

         水题,排列组合。推出公式C(m+n,较小的那个数) 

    代码:

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <sstream>
     4 #include <cstdlib>
     5 #include <cstring>
     6 #include <cstdio>
     7 #include <string>
     8 #include <bitset>
     9 #include <vector>
    10 #include <queue>
    11 #include <stack>
    12 #include <cmath>
    13 #include <list>
    14 //#include <map>
    15 #include <set>
    16 using namespace std;
    17 /***************************************/
    18 #define ll long long
    19 #define int64 __int64
    20 #define PI 3.1415927
    21 /***************************************/
    22 const int INF = 0x7f7f7f7f;
    23 const double eps = 1e-8;
    24 const double PIE=acos(-1.0);
    25 const int d1x[]= {0,-1,0,1};
    26 const int d1y[]= {-1,0,1,0};
    27 const int d2x[]= {0,-1,0,1};
    28 const int d2y[]= {1,0,-1,0};
    29 const int fx[]= {-1,-1,-1,0,0,1,1,1};
    30 const int fy[]= {-1,0,1,-1,1,-1,0,1};
    31 const int dirx[]= {-1,1,-2,2,-2,2,-1,1};
    32 const int diry[]= {-2,-2,-1,-1,1,1,2,2};
    33 /*vector <int>map[N];map[a].push_back(b);int len=map[v].size();*/
    34 /***************************************/
    35 void openfile()
    36 {
    37     freopen("data.in","rb",stdin);
    38     freopen("data.out","wb",stdout);
    39 }
    40 priority_queue<int> qi1;
    41 priority_queue<int, vector<int>, greater<int> >qi2;
    42 /**********************华丽丽的分割线,以上为模板部分*****************/
    43 
    44 int main()
    45 {
    46     //zuhe();
    47     long long n,m;
    48     while(scanf("%lld%lld",&n,&m)&&(n+m))
    49     {
    50         long long tt,t;
    51         if (m<n)
    52         {
    53             t=n;
    54             n=m;
    55             m=t;
    56         }
    57         t=n;
    58         tt=m+n;
    59         double ce=1.0;
    60         while(t)
    61         {
    62             ce=(double)(ce*tt)/(double)t;
    63             t--;
    64             tt--;
    65         }
    66         printf("%.0lf
    ",ce);
    67     }
    68     return 0;
    69 }
    View Code
  • 相关阅读:
    PL/SQL Developer 远程连接oracle数据库
    Python 类与对象 __init__()参数
    微信公众号--发送模板消息
    微信公众号--进入菜单之前获取用户信息
    微信公众号-自定义菜单
    Java--时间转换
    微信公众号--被动回复用户消息
    {"errcode":40017,"errmsg":"invalid button type hint: [I8nq_a0783sha1]"}
    在使用XStream时没有processAnnotations方法
    在idea的控制台中中文显示为乱码
  • 原文地址:https://www.cnblogs.com/ZhaoPengkinghold/p/4002706.html
Copyright © 2020-2023  润新知