Java教程

寒假学习记录D16

本文主要是介绍寒假学习记录D16,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.OpenCV

2.web前端-CSS

3.算法基础练习


(1)OpenCV

 

 


(2)web前端 

 

 

 

 

 


 (3)算法基础练习

题目描述

赛时提示:保证出发点和终点都是空地

帕秋莉掌握了一种木属性魔法

这种魔法可以生成一片森林(类似于迷阵),但一次实验时,帕秋莉不小心将自己困入了森林

帕秋莉处于地图的左下角,出口在地图右上角,她只能够向上或者向右行走

现在给你森林的地图,保证可以到达出口,请问有多少种不同的方案

答案对2333取模

输入描述:

第一行两个整数m , n表示森林是m行n列
接下来m行,每行n个数,描述了地图
0  -  空地
1  -  树(无法通过)

输出描述:

一个整数表示答案

示例1

输入

3 3
0 1 0
0 0 0
0 0 0

输出

3

备注:

对于30%的数据,n,m≤100
对于100%的数据,n,m≤3,000
数据规模较大,请使用较快的输入方式,以下为快速读入模板

template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}

scanf("%d",&x)  ->  read(x)
cin>>x -> read(x)

(调用方式:read(要读入的数))

 

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include<iostream>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define space putchar(' ')
#define enter putchar('\n')
typedef pair<int,int> PII;
const int mod=1e4+7;
const int N=2e6+10;
const int inf=0x7f7f7f7f;


ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}

template <class T>
void read(T &x)
{
    char c;
    bool op = 0;
    while(c = getchar(), c < '0' || c > '9')
        if(c == '-')
            op = 1;
    x = c - '0';
    while(c = getchar(), c >= '0' && c <= '9')
        x = x * 10 + c - '0';
    if(op)
        x = -x;
}
template <class T>
void write(T x)
{
    if(x < 0)
        x = -x, putchar('-');
    if(x >= 10)
        write(x / 10);
    putchar('0' + x % 10);
}

int fa[N];
int n,m;
int a[3005][3005];
int dp[3005][3005];
int vis[3005][3005];
int main()
{
    read(n),read(m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        read(a[i][j]);
        if(a[i][j]==1)vis[i][j]=1;
    }
    vis[n][1]=1;
    dp[n][1]=1;
    for(int i=n;i>=1;i--)
        for(int j=1;j<=m;j++)
    {
        if(!vis[i][j])
        {
                dp[i][j]=(dp[i+1][j]+dp[i][j-1])%2333;
        }
    }
    write(dp[1][m]);


    return 0;
}








这篇关于寒假学习记录D16的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!