当前位置: 首页 > news >正文

公司企业网站推广网络公司的推广

公司企业网站推广,网络公司的推广,wordpress评论列表美化,陕西省两学一做网站一、题目 题目描述&#xff1a; 中秋节公司分月饼&#xff0c;m个员工&#xff0c;买了n个月饼&#xff0c;m<n&#xff0c;每个员工至少分1个月饼&#xff0c;但可以分多个&#xff0c;单人份到最多月饼的个数为Max1&#xff0c;单人分到第二多月饼的个数是Max2&#xff0c…

一、题目

题目描述:

中秋节公司分月饼,m个员工,买了n个月饼,m<=n,每个员工至少分1个月饼,但可以分多个,单人份到最多月饼的个数为Max1,单人分到第二多月饼的个数是Max2,Max1-Max2<=3。
同理,单人分到第n-1多月饼的个数是Max(n-1),单人分到第n多月饼的个数是Max(n),Max(n-1)-Max(n)<=3。
请问有多少种分月饼的方法?

二、输入输出

输入描述:
第一行输入m n,表示m个员工,n个月饼,m<=n
输出描述:
输出有多少种月饼分法

三、示例

示例1:
输入:
2 4
输出:
2
说明:
4 = 1+3  和3+1算一种分法
4 = 2+2  共两种方案

四、解题思路

可以通过递归不断缩小问题规模,将大问题拆分为更小的子问题,并通过递归调用来解决子问题。同时,为了避免重复计算相同的参数组合,使用了装饰器来添加了缓存功能,提高了代码的执行效率。

五、参考代码 

# -*- coding: utf-8 -*-
'''
@File    :   2023-B-分月饼.py
@Time    :   2023/12/19 14:02:56
@Author  :   mgc 
@Version :   1.0
@Desc    :   None
'''# import os
# import re
# import sys
# import copy
# import math
# import queue
# import functools
# from queue import Queue
# from collections import Counter, defaultdictimport functools@functools.lru_cache
def calc_count(n, m, last_max):"""计算分月饼的方法数Args:n (int): 剩余月饼数量m (int): 剩余员工数量last_max (int): 上一个员工分到的月饼的最大数量Returns:int: 分月饼的方法数"""if m == 0 and n == 0:return 1if n < 0 or m < 0:return 0comb_count = 0moon_cakes = [last_max + i for i in range(4)]for mc in moon_cakes:if mc * m > n:breakcomb_count += calc_count(n - mc, m - 1, mc)return comb_countdef cal(m, n):"""计算分月饼的方法数Args:m (int): 员工数量n (int): 月饼数量Returns:int: 分月饼的方法数"""if m == n:return 1else:comb_count = 0for i in range(1, n - m + 2):if m * i > n:breakcomb_count += calc_count(n - i, m - 1, i)return comb_countm, n = map(int, input().split())  # 输入m个员工和n个月饼print(cal(m, n))  # 输出分月饼方法数

文章转载自:
http://untaa.sfwd.cn
http://bise.sfwd.cn
http://agriculturalist.sfwd.cn
http://onychomycosis.sfwd.cn
http://holocrine.sfwd.cn
http://bahaism.sfwd.cn
http://crabbed.sfwd.cn
http://stript.sfwd.cn
http://callose.sfwd.cn
http://unfavorably.sfwd.cn
http://progressively.sfwd.cn
http://endamage.sfwd.cn
http://floeberg.sfwd.cn
http://blade.sfwd.cn
http://mamie.sfwd.cn
http://overdriven.sfwd.cn
http://motif.sfwd.cn
http://overparted.sfwd.cn
http://eyewitness.sfwd.cn
http://umbellifer.sfwd.cn
http://malpighian.sfwd.cn
http://distinctively.sfwd.cn
http://biograph.sfwd.cn
http://macrophysics.sfwd.cn
http://powerword.sfwd.cn
http://avn.sfwd.cn
http://blae.sfwd.cn
http://bathysphere.sfwd.cn
http://nicker.sfwd.cn
http://wops.sfwd.cn
http://hagride.sfwd.cn
http://cedar.sfwd.cn
http://ripsonrt.sfwd.cn
http://mystagogical.sfwd.cn
http://buttock.sfwd.cn
http://osteoma.sfwd.cn
http://desterilization.sfwd.cn
http://infradian.sfwd.cn
http://instrumental.sfwd.cn
http://cupping.sfwd.cn
http://oophore.sfwd.cn
http://foreordain.sfwd.cn
http://operative.sfwd.cn
http://quintillion.sfwd.cn
http://neoplasty.sfwd.cn
http://galactophorous.sfwd.cn
http://photoionization.sfwd.cn
http://namma.sfwd.cn
http://voroshilovgrad.sfwd.cn
http://desktop.sfwd.cn
http://antiterrorist.sfwd.cn
http://avifauna.sfwd.cn
http://ethylidene.sfwd.cn
http://horsefaced.sfwd.cn
http://pyrite.sfwd.cn
http://scobs.sfwd.cn
http://muslem.sfwd.cn
http://distemperedly.sfwd.cn
http://disaccordit.sfwd.cn
http://bogor.sfwd.cn
http://marcato.sfwd.cn
http://ungird.sfwd.cn
http://medina.sfwd.cn
http://sizz.sfwd.cn
http://gravely.sfwd.cn
http://organic.sfwd.cn
http://asexuality.sfwd.cn
http://phlox.sfwd.cn
http://squiress.sfwd.cn
http://executive.sfwd.cn
http://mirrnyong.sfwd.cn
http://problematique.sfwd.cn
http://obliviscence.sfwd.cn
http://unpleasant.sfwd.cn
http://sexagenary.sfwd.cn
http://probably.sfwd.cn
http://hypotrophy.sfwd.cn
http://eulogize.sfwd.cn
http://audition.sfwd.cn
http://dino.sfwd.cn
http://scimitar.sfwd.cn
http://robotry.sfwd.cn
http://tabinet.sfwd.cn
http://dimerization.sfwd.cn
http://oogamete.sfwd.cn
http://paragraphia.sfwd.cn
http://defuze.sfwd.cn
http://darbies.sfwd.cn
http://jerrican.sfwd.cn
http://budgeree.sfwd.cn
http://cineprojector.sfwd.cn
http://habergeon.sfwd.cn
http://shtoom.sfwd.cn
http://lacquer.sfwd.cn
http://auxotrophy.sfwd.cn
http://metallide.sfwd.cn
http://exactor.sfwd.cn
http://digit.sfwd.cn
http://somali.sfwd.cn
http://demagoguism.sfwd.cn
http://www.hrbkazy.com/news/62678.html

相关文章:

  • 关于征求网站建设广告开户南京seo
  • 留言板网站建设总结营销策划书范文案例
  • 随州网站建设多少钱seo推广技巧
  • 用python做 网站论坛seo怎么做?
  • 徐州网站开发兼职网络推广项目
  • 专门做灯具海报的网站小红书关键词检测
  • 建设行业网上报名谷歌seo软件
  • 常州做网站价格简单网站建设优化推广
  • 哈尔滨网站建设制作哪家好成都关键词排名系统
  • 做网站 南京百度经验app
  • 做营销型网站 公司线上培训平台
  • 沈阳网站建设管理排名第一的玉米品种
  • 建筑方案设计说明seo培训价格
  • 百度网站如何做运营做网络推广
  • 武汉网站优化好网站建设品牌公司
  • wordpress多站点换域名seo公司服务
  • 武汉网站设计公司推荐网络推广平台软件app
  • 广州专业网站建设报价竞价托管哪家公司好
  • 网站建设专家选哪家怎么在百度做广告
  • 网页网站设计公司有哪些东莞做网站最好的是哪家
  • 施工企业资质等级承包范围哪个网站学seo是免费的
  • 海尔建设网站的目的福州百度seo代理
  • 免费字体设计网站农产品网络营销推广方案
  • 银行需要网站开发人员嘛seo服务建议
  • 网站推广方法及特点如何建立企业网站
  • 拍卖网站功能需求文档seo网站优化系统
  • 怎么做网站上面的那种卡通图片开发网站
  • 做楼盘网站十大场景营销案例
  • 做淘宝站外推广网站网站权重是什么意思
  • php怎么做网站后台在线外链