ICode9

精准搜索请尝试: 精确搜索
  • buy a ticket2020-05-27 14:02:54

    题目 Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well. There are n cities in Berland. People can travel between cities using two-di

  • 力扣题解-LCP 06. 拿硬币2020-05-17 21:53:35

    题目描述 桌上有 n 堆力扣币,每堆的数量保存在数组 coins 中。我们每次可以选择任意一堆,拿走其中的一枚或者两枚,求拿完所有力扣币的最少次数。 示例 1: 输入:[4,2,1] 输出:4 解释:第一堆力扣币最少需要拿 2 次,第二堆最少需要拿 1 次,第三堆最少需要拿 1 次,总共 4 次即可拿完。 示例 2:

  • leetcode322.零钱兑换2020-05-13 18:44:25

    题目大意 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1 示例 1: 输入: coins = [1, 2, 5], amount = 11 输出: 3 解释: 11 = 5 + 5 + 1 示例 2: 输入: coins = [2

  • LeetCode 518. 零钱兑换 II(动态规划)2020-05-13 18:43:59

    1. 题目 给定不同面额的硬币和一个总金额。 写出函数来计算可以凑成总金额的硬币组合数。 假设每一种面额的硬币有无限个。 示例 1: 输入: amount = 5, coins = [1, 2, 5] 输出: 4 解释: 有四种方式可以凑成总金额: 5=5 5=2+2+1 5=2+1+1+1 5=1+1+1+1+1 示例 2: 输入: amoun

  • Codeforces Round #638 A.Phoenix and Balance(水题)2020-05-02 14:51:16

    Phoenix has nn coins with weights 21,22,…,2n21,22,…,2n. He knows that nn is even. He wants to split the coins into two piles such that each pile has exactly n2n2 coins and the difference of weights between the two piles is minimized. Formally, let aa deno

  • dp背包 面试题 08.11. 硬币2020-04-29 20:58:50

    https://leetcode-cn.com/problems/coin-lcci/   硬币。给定数量不限的硬币,币值为25分、10分、5分和1分,编写代码计算n分有几种表示法。(结果可能会很大,你需要将结果模上1000000007) 示例1: 输入: n = 5 输出:2 解释: 有两种方式可以凑成总金额:5=55=1+1+1+1+1示例2: 输入: n = 1

  • UVA - 11300 Spreading the Wealth(公式推导)2020-04-08 22:53:38

    DescriptionA Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyonearound a circular table. First, everyone has converted all of their properties to coins of equal value,such that the total number of coins i

  • POJ 1742(Coins)2020-04-05 13:07:17

    题目链接:http://poj.org/problem?id=1742   与一般的背包问题不一样,这是要计算满足条件的情况的数量,而不是计算最值,一开始的思路就是按照书上的类比: dp[i][j] := 用前i种硬币能否凑成j 递推:dp[i][j] = (dp[i – 1][j – k * A[i]])为真的时候 但是 MLE,其实一点都不惊讶吧,数组开那么

  • 动态规划的理解2020-04-01 18:00:14

    前言 动态规划(dynamic programming,简称 dp)是工程中非常重要的解决问题的思想,从我们在工程中地图软件上应用的最短路径问题,再在生活中的在淘宝上如何凑单以便利用满减券来最大程度地达到我们合理薅羊毛的目的 ,很多时候都能看到它的身影。 不过动态规划对初学者来说确实比较难,dp状

  • Leetcode C++《热题 Hot 100-52》322. 零钱兑换2020-03-17 12:41:28

    Leetcode C++《热题 Hot 100-52》322. 零钱兑换 题目 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。 示例 1: 输入: coins = [1, 2, 5], amount = 11 输出: 3 解

  • PAT A1048 Find Coins (25分)(二分法)2020-03-13 12:42:01

    题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805432256675840 题目描述 Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accep

  • eetcode必要技巧--动态规划(一)2020-03-09 13:55:02

    首先我们要搞清楚什么是动态规划 动态规划是运筹学中用于求解决策过程中的最优化数学方法。当然,我们在这里关注的是作为一种算法设计技术,作为一种使用多阶段决策过程最优的通用方法。 当然这个很难理解,但是按照本人的理解. 实际上就是一个种类的问题. 在这个问题中,我们只需要

  • 刷题37——零钱兑换(力扣)2020-03-08 20:56:05

    69. 零钱兑换 题目链接 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/coin-change 题目描述 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。 示例 1: 输入:

  • 322.零钱兑换(动态规划和贪心)2020-03-08 19:58:29

    322. 零钱兑换 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/coin-change 著作权归领扣网络所有。商业转载请

  • Leetcode322.零钱兑换2020-03-08 19:02:05

    思路: 一开始想起来的就是给现有的零钱进行排序,然后选取最大面值的零钱,进行回溯,找到就立即退出,这样的做法没有考虑到1,7,10 amount = 14这种情况,10,1,1,1,1与7,7肯定是最少两个硬币。如果说遍历所有的情况,不提前退出,会出现超时的情况。那么回溯的时候不用每次都只减一个coins[i

  • [PAT-A 1068]Find More Coins2020-03-07 20:03:23

    题目大意: 有N枚硬币,给出每枚硬币的价值,现在要用这些硬币去支付价值为M的东西。 问是否可以找见这样的方案,使得选择用来支付的硬币价值之和恰好为M,如果不存在,输出NoSolution。 如果存在,从小到大输出选择用来支付硬币的价值,如果有多种方案,则输出字典序最小的那个。 思路: 题目

  • 零钱兑换2020-02-26 10:06:49

    使用动态规划 时间复杂度为O(amount*n) 空间复杂度为O(amount) public int coinChange(int[] coins, int amount) { if(amount==0){ return 0; } int[] ans=new int[amount+1]; ans[0]=0; for(int i=1;i<ans.length

  • ACM - False Coin2020-02-20 20:45:58

    False Coin The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in weight from other coins (while all other coins are equal in weight). After the economic crisis

  • PAT (Advanced Level) Practice 1068 Find More Coins(30分)【动态规划:01背包】2020-02-07 18:01:04

    Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for

  • LeetCode 322. 零钱兑换(动态规划)2020-02-03 21:41:38

    题目描述 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。 示例 1: 输入: coins = [1, 2, 5], amount = 11 输出: 3 解释: 11 = 5 + 5 + 1 示例 2: 输入: coins = [2

  • Piggy-Bank2020-02-02 20:02:06

    Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any small money, he take

  • 算法题 背包问题-05-Coins2020-02-02 15:39:36

    Whuacmers use coins.They have coins of value A1,A2,A3…An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in a nearby shop. He wanted to pay the exact price(without change) and he known

  • Codeforces 1294A Collecting Coins2020-02-01 23:04:30

    传送门 题意: 给4个整数,\(a,b,c,n\),然后把分成3份分别位A,B,C,(A+B+C=n) 问是否有一种分的方式满足 \(a + A = b + B = c + C\) 满足输出yes,否则输出no 思路: 如果a+b+c+n不是3的倍数,肯定不满足,从题目中可以看出,A,B,C>=0,判断一下即可 代码: #include <iostream> #include <stdio.h> #

  • A. Collecting Coins2020-01-27 12:39:05

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has aa coins, Barbara has bb coins and Ce

  • 【LeetCode】322. Coin Change2020-01-27 09:06:22

    322. Coin Change Description: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有