题解 | 二维斐波那契数列

二维斐波那契数列

https://www.nowcoder.com/practice/a1951ca9431646ff8f9bc6f6d24d1e0a

写个最暴力的记忆化搜索爽一下

from sys import stdin,stdout,setrecursionlimit
from math import *
from functools import *
input = stdin.readline
print = stdout.write

n,m = map(int,input().split())
setrecursionlimit(1000000)
@lru_cache(maxsize=100000)
def dfs(x,y):
    if x == 1 and y == 1:
        return 1
    if x == 1:
        return dfs(x,y-1)
    if y == 1:
        return dfs(x-1,y)
    return (dfs(x-1,y)+dfs(x,y-1))%1000000007

print(str(dfs(n,m)))

全部评论

相关推荐

点赞 评论 收藏
分享
03-26 12:00
已编辑
门头沟学院 Java
offer魅魔_oc...:100-200每天,你还要倒贴100
点赞 评论 收藏
分享
03-13 14:21
已编辑
江西警察学院 前端工程师
站队站对牛:红红一大片 天都要塌了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务