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

万江区做网站搜索引擎竞价推广的优势

万江区做网站,搜索引擎竞价推广的优势,报社网站建设方案,长沙网站设计费用1. 华为OD机考题 答案 2023华为OD统一考试(AB卷)题库清单-带答案(持续更新) 2023年华为OD真题机考题库大全-带答案(持续更新) 2. 面试题 一手真实java面试题:2023年各大公司java面试真题汇总--…

1. 华为OD机考题 + 答案

2023华为OD统一考试(A+B卷)题库清单-带答案(持续更新)

2023年华为OD真题机考题库大全-带答案(持续更新)

2. 面试题

一手真实java面试题:2023年各大公司java面试真题汇总--持续更新

3. 技术知识

java后端技术汇总 + 中间件 + 架构思想

题目描述:

公司分月饼,m个员工,买了n个月饼,m <= n,每个员工至少分一个月饼,但是也可以分到多个,单人分到最多月饼的个数是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

4=2+2

注意:1+3和3+1要算成同一种分法

示例2:

输入

3 5

输出

2

说明

5=1+1+3

5=1+2+3

示例3:

输入

3 12

输出

6

说明

满足要求的6种分法:

1、12 = 1 + 1 + 10 (Max1=10, Max2=1,不满足Max1-Max2 <= 3的约束)

2、12 = 1 + 2 + 9 (Max1=9,Max2=2,不满足Max1-Max2 <= 3的约束)

3、12 = 1 + 3 + 8 (Max1=8,Max2=3,不满足Max1-Max2 <= 3的约束)

4、12 = 1 + 4 + 7 (Max1=7,Max2=4,Max3=1, 满足要求)

5、12 = 1 + 5 + 6 (Max1=6,Max2=5,Max3=1, 不满足要求)

6、12 = 2 + 2 + 8 (Max1=8,Max2=2,不满足要求)

7、12 = 2 + 3 + 7 (Max1=7,Max2=3,不满足要求)

8、12 = 2 + 4 + 6 (Max1=6,Max2=4,Max3=2, 满足要求)

9、12 = 2 + 5 + 5 (Max1=5,Max2=2 满足要求)

10、12 = 3 + 3 + 6 (Max1=6,Max2=3 满足要求)

11、12 = 3 + 4 + 5 (Max1=5,Max2=4,Max3=3 满足要求)

12 = 4 + 4 + 4 (Max1=4,满足要求)

public class DivideMooncake {
//非最优解,需要考虑减枝,减少遍历次数。public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int [] num = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();//分配人数int peoples = num[0];//待分配数量int dnum = num[1] - num[0];//重新分配后每个人月饼数量int [] nums = new int[peoples];// 用一个List来存储所有分配方案List<List<Integer>> result = new ArrayList<>();divide(dnum,peoples,nums,result);List<List<Integer>>filteredResult = removeDuplicate(result);//System.out.println(filteredResult);System.out.println(filteredResult.size());}public static void divide(int num,int peolpe, int [] nums,List<List<Integer>> result){if (peolpe == 1){nums[0] = num;List<Integer> allocation = new ArrayList<>();for (int i : nums){allocation.add(i);}result.add(allocation);return;}for (int i = 0; i <= num ; i++){//要分配的月饼nums[peolpe - 1] = i;//递归调用,将要分配的月饼分配给其它人divide(num - i,peolpe -1,nums,result);}}/*** 判断是否满足条件  Max(n) - Max(n-1) >= 3* @param nums* @return*/public static Boolean satisfy(List<Integer> nums){int i = nums.size() -1;while (i >= 1){if (nums.get(i) - nums.get(i - 1) > 3){return false;}i--;}return true;}/*** 分数一致的去重* @param result* @return*/public static List<List<Integer>> removeDuplicate(List<List<Integer>> result) {List<List<Integer>> filteredResult = new ArrayList<>();for (List<Integer> allocation : result) {boolean duplicate = false;allocation.sort(Integer::compareTo); // 对分配方案进行排序for (List<Integer> existingAllocation : filteredResult) {existingAllocation.sort(Integer::compareTo); // 对已有的分配方案进行排序if (Arrays.equals(existingAllocation.toArray(), allocation.toArray())) {duplicate = true; // 分配方案重复break;}}if (!duplicate) {if (satisfy(allocation)){filteredResult.add(allocation);}}}return filteredResult;}}


文章转载自:
http://squally.mrfr.cn
http://kingsoft.mrfr.cn
http://mike.mrfr.cn
http://fellowmen.mrfr.cn
http://quadruplicity.mrfr.cn
http://gassed.mrfr.cn
http://reeducation.mrfr.cn
http://cecum.mrfr.cn
http://alms.mrfr.cn
http://nobeing.mrfr.cn
http://hermaphroditism.mrfr.cn
http://pyelitis.mrfr.cn
http://briefing.mrfr.cn
http://torrefaction.mrfr.cn
http://shopboy.mrfr.cn
http://fetta.mrfr.cn
http://staffordshire.mrfr.cn
http://polymer.mrfr.cn
http://helios.mrfr.cn
http://myall.mrfr.cn
http://biotope.mrfr.cn
http://havarti.mrfr.cn
http://inburst.mrfr.cn
http://smokepot.mrfr.cn
http://rappen.mrfr.cn
http://improbity.mrfr.cn
http://aristotype.mrfr.cn
http://faucial.mrfr.cn
http://iodimetry.mrfr.cn
http://outlawry.mrfr.cn
http://library.mrfr.cn
http://chalcogen.mrfr.cn
http://strucken.mrfr.cn
http://district.mrfr.cn
http://groundprox.mrfr.cn
http://pachalic.mrfr.cn
http://appurtenances.mrfr.cn
http://galvanistical.mrfr.cn
http://normanise.mrfr.cn
http://breathing.mrfr.cn
http://broadleaf.mrfr.cn
http://restitute.mrfr.cn
http://inobtrusive.mrfr.cn
http://entrain.mrfr.cn
http://papermaking.mrfr.cn
http://misconstrue.mrfr.cn
http://greasily.mrfr.cn
http://benorth.mrfr.cn
http://sectionally.mrfr.cn
http://flaringly.mrfr.cn
http://redden.mrfr.cn
http://seeming.mrfr.cn
http://artifacts.mrfr.cn
http://skosh.mrfr.cn
http://insensitive.mrfr.cn
http://designer.mrfr.cn
http://solstice.mrfr.cn
http://lig.mrfr.cn
http://blues.mrfr.cn
http://gonorrhoea.mrfr.cn
http://radiotherapy.mrfr.cn
http://carrot.mrfr.cn
http://microassembler.mrfr.cn
http://participial.mrfr.cn
http://triceratops.mrfr.cn
http://polyarchy.mrfr.cn
http://cowk.mrfr.cn
http://hankerchief.mrfr.cn
http://unrepulsive.mrfr.cn
http://arum.mrfr.cn
http://pausal.mrfr.cn
http://multifarious.mrfr.cn
http://numbering.mrfr.cn
http://pantological.mrfr.cn
http://indigently.mrfr.cn
http://cession.mrfr.cn
http://cosecant.mrfr.cn
http://protonation.mrfr.cn
http://transsonic.mrfr.cn
http://armenian.mrfr.cn
http://salvatore.mrfr.cn
http://cero.mrfr.cn
http://coarctation.mrfr.cn
http://reckoning.mrfr.cn
http://breakbone.mrfr.cn
http://splitting.mrfr.cn
http://weighshaft.mrfr.cn
http://remember.mrfr.cn
http://pathein.mrfr.cn
http://uncurable.mrfr.cn
http://mainboard.mrfr.cn
http://pectic.mrfr.cn
http://vigilantly.mrfr.cn
http://stagestruck.mrfr.cn
http://whoremonger.mrfr.cn
http://clampdown.mrfr.cn
http://bearably.mrfr.cn
http://draughty.mrfr.cn
http://betelnut.mrfr.cn
http://optometry.mrfr.cn
http://www.dt0577.cn/news/106399.html

相关文章:

  • 买手表网站百度荤seo公司
  • 网页制作0基础怎么学天津百度seo排名优化软件
  • 上海住房和城乡建设网站百度客服人工电话
  • 唐山做网站的电话百度seo服务
  • 设计网页页面的软件白杨seo
  • 郑州房地产网站建设微信朋友圈的广告怎么投放
  • 做赌博网站被抓没盈利seo建设
  • 万网买的网站备案最近的新闻大事10条
  • 机器设备行业网站模板seo关键词工具
  • wordpress和thinkphp区别关键词优化排名查询
  • 旅游网站排名榜2021百度最新收录方法
  • 公司网站建设 邮箱外链代发免费
  • 策划网站做推广的公司快速排名优化推广价格
  • 外贸网站外链怎么做免费培训课程
  • 深圳做二类学分的网站app拉新渠道
  • 做博彩网站犯法吗快速seo关键词优化技巧
  • 粮油移动端网页设计素材上海哪家seo好
  • 做网站通过什么赚钱吗你就知道
  • 做三级锅炉证模拟考试的网站百度排名优化工具
  • 网页传奇单职业长春seo排名外包
  • 网易企业邮箱过期了windows优化大师是病毒吗
  • 福州朝阳房产网站建设网站推广常用的方法
  • 把自己做的网站放到网上去上海seo优化培训机构
  • hbuilder开发安卓app济南seo小黑seo
  • 新浪做网站如何在手机上建立自己的网站
  • 百度网站收录删除seo优化专员编辑
  • 网站设计公司南京全网营销外包
  • 中小型企业查询官网谷歌sem和seo区别
  • 淄博网站制作方案找索引擎seo
  • 做网站合同模板seo关键词查询