808. 分汤 有 A 和 B 两种类型的汤.一开始每种类型的汤有 N 毫升.有四种分配操作: 提供 100ml 的汤A 和 0ml 的汤B. 提供 75ml 的汤A 和 25ml 的汤B. 提供 50ml 的汤A 和 50ml 的汤B. 提供 25ml 的汤A 和 75ml 的汤B. 当我们把汤分配给某人之后,汤就没有了.每个回合,我们将从四种概率同为0.25的操作中进行分配选择.如果汤的剩余量不足以完成某次操作,我们将尽可能分配.当两种类型的汤都分配完时,停止操作. 注意不存在先分配100…
575. 分糖果 给定一个偶数长度的数组,其中不同的数字代表着不同种类的糖果,每一个数字代表一个糖果.你需要把这些糖果平均分给一个弟弟和一个妹妹.返回妹妹可以获得的最大糖果的种类数. 示例 1: 输入: candies = [1,1,2,2,3,3] 输出: 3 解析: 一共有三种种类的糖果,每一种都有两个. 最优分配方案:妹妹获得[1,2,3],弟弟也获得[1,2,3].这样使妹妹获得糖果的种类数最多. 示例 2 : 输入: candies = [1,1,2,3] 输出: 2 解析: 妹妹获得…
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123" "132" "213" "231" "312" "…
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). The function p…
hdu1006 标签(空格分隔): 暴力枚举 好久没有打题了,退队了有好几个月了,从心底不依赖那个人了,原来以为的爱情戏原来都只是我的独角戏.之前的我有时候好希望有个人出现,告诉自己去哪里,做什么,哪种仅仅是渴望被爱的感觉都很美好,大概是因为离开了acm也不再依赖他所以现在我自己告诉自己,自己要去哪里,做什么,突然感觉很踏实,也不那么累了.现在我想把之前没有做好的做好,虽然我已经失去了最好的时机,但还是要在最忙的时间里抽出来做一些曾经有所遗憾的事情. 不多说了,上题! 开始推了半天公式,发现这个…
链接:https://www.nowcoder.com/acm/contest/138/D来源:牛客网 小胖参加了人生中最重要的比赛——MedoC资格赛.MedoC的资格赛由m轮构成,使用常见的“加权标准分”的规则.每位选手需要参加所有的m轮的比赛.在一轮中,能取得的分数为自己的成绩除掉最高分的成绩.每个选手的总分为每一轮获得的分数乘上这一轮比赛占得比重.如果在某一轮比赛中所有人获得了零分,那么所有选手在这一轮获得的分数都为0分. 比如说,资格赛一共3轮,三轮的权重分别为30%, 30%, 40…
作者:小傅哥 博客:https://bugstack.cn - 原创系列专题文章 沉淀.分享.成长,让自己和他人都能有所收获! 一.前言 能力,是你前行的最大保障 年龄会不断的增长,但是什么才能让你不慌张.一定是能力,即使是在一个看似还很安稳的工作中也是一样,只有拥有能留下的本事和跳出去的能力,你才会是安稳的.而能力的提升是不断突破自己的未知也就是拓展宽度,以及在专业领域建设个人影响力也就是深度.如果日复日365天,天天搬砖,一切都没有变化的重复只能让手上增长点老茧,岁月又叹人生苦短. 站得高看…
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Ensure that numbers within the set are sorted in ascending order. Example 1…
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaaa&qu…
Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same le…