ICode9

精准搜索请尝试: 精确搜索
  • PAT甲级——A1048 Find Coins2019-07-31 13:52:41

    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 ea

  • [LeetCode]Coin Change@Python2019-07-17 10:35:25

    Coin Change 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 combination of t

  • 441. Arranging Coins2019-07-16 09:04:56

    You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can be formed. n is a non-negative integer and fits within the range

  • 1048 Find Coins (25 分)2019-07-14 19:01:56

    1048 Find Coins (25 分)   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 re

  • 野生前端的数据结构练习(12)贪心算法2019-07-10 10:04:47

    【摘要】 贪心算法求解背包问题实际上很像人工求解,如果你是一个大盗,自己带着背包在宝库挑东西,总不能拿一张草稿纸出来开始动态规划或手动递归吧,那等你求出结果来估计警察也来了。 参考代码可见:https://github.com/dashnowords/blogs/tree/master/Structure/GreedyAlogrithm 一.

  • leetcode笔记——背包问题总结22019-06-16 16:54:29

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

  • 2019-06-12:情景题2019-06-12 09:53:32

    """ 假设有10个锁仓货币,每天释放(即变为非锁仓状态)它的 1/180个货币, 我要计算每天的释放量和剩余量,结果保留小数点后4位, 其余截掉当锁仓货币小于0.1的时候,程序结束 """ coins=10 releaseCoin=1/180 remain=0 def remainCoin(coins): coins=coins-coins*releaseCoin i=1

  • POJ1742 Coins 多重背包+贪心2019-06-09 15:40:34

    Vjudge传送门   $Sol$ 首先发现这是一个多重背包,所以可以用多重背包的一般解法(直接拆分法,二进制拆分法...)  但事实是会TLE,只能另寻出路 本题仅关注“可行性”(面值能否拼成)而不是“最优性”,这是一个特殊之处。 从这里找优化 在“最优性”的问题中,$f[j]$从$f[j]$或$f[j-a[i]]$中

  • 动态规划-背包问题2019-06-05 22:49:47

    0-1背包 N件物品,背包最大容量为V, 第i件物品的费用为w[i],价值为v[i] 使用f[i][j]表示在容量为j,在前i件物品中(包括i)选择物品所获得的最大价值 递推方程为f[i][j] = max(f[i-1][j], f[i-1][j - w[i]] + v[i]) 在是否选择第i件物品取最大值 从后往前更新就可以使用一维数组简化f[j]

  • leetcode-mid-dynamic programming-322. Coin Change - NO2019-06-05 13:01:45

    mycode 我开始错误的思路:先用大钱除总钱数来保证 fewest number of coins,当最后剩下的amount小于最小币值的货币时,就说明return -1,但是这样想是有问题的!!! 例如:[1,4,5]   12=5*2+2    12 =5*2 + 1*2 用了4枚,但是12 = 4*3 因为还有下一步,也就是用次大的币值去重复这个步骤!!而且也

  • H - Gold Coins(2.4.1)2019-05-30 14:53:11

    H - Gold Coins(2.4.1) Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Description The king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coi

  • 近期的做题总结2019-05-26 20:52:48

    noi2014 noi2015 noi2016 noi2017 noi2018 gym102056AExotic … Ancient City   gym102056BMysterious … Host   gym102056CHeretical … Möbius   gym102056EImmortal … Universe 咕咕咕 gym102056FInterstellar … Fantasy gym102056GOmnipotent … Garland gym102056HSain

  • Coins2019-05-26 09:53:58

    POJ 题意:\(N(N<=100)\)种硬币,第\(i\)种硬币的面值为\(a_i\),共有\(c_i(c_i<=1000)\)个.求\(1\)~\(M(M<=10^5)\)之间能被拼成的面值有多少个? 分析:设\(bj[j]=1/0\)表示面值\(j\)能/不能被拼出来,\(num[j]\)表示\(bj[j]\)在阶段i时被拼出来至少需要用多少枚第i种硬币. 对于一个数

  • POJ-1787 Charlie's Change (完全背包+输出方案)2019-05-22 09:52:00

    Charlie's ChangeTime Limit: 1000MS   Memory Limit: 30000KTotal Submissions: 4505   Accepted: 1420Description Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests

  • 四剑客 awk上2019-05-20 09:49:39

    awk grep sed 混合用法 awk 固定格式 awk ‘{print $NF}’ $NF文件中最后一个 倒数第二个为 NF−1还可以在NF -1 还可以在NF−1还可以在NF之前加 各种符号 awk -F : ‘{}’ -F:表示以:分割 awk ‘{print NR $1,$2,$3}’ +文件名 显示前三列以及行号 awk ‘{print N

  • 【题解】Coins(二进制拆分+bitset)2019-05-15 13:43:22

    【题解】Coins(二进制拆分+bitset) 【vj】 俗话说得好,bitset大法吼啊 这道题要不是他多组数据卡死了我复杂度算出来等于九千多万的选手我还不会想这种好办法233 考虑转移的实质是怎样的,就是对于一个\(dp\)数组表,平移\(val_i \times num_i'\)位然后异或起来,这样就直接bitset开就好了

  • 零钱兑换2019-05-13 12:48:12

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

  • Leetcode 题解 - 动态规划-0-1 背包(6):硬币找零之二找零钱的硬币数组合2019-05-07 09:56:09

    [LeetCode] Coin Change 2 硬币找零之二   You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind

  • Codeforces Round #156 (Div. 2)E. Furlo and Rublo and Game【SG】2019-04-24 13:56:33

    E. Furlo and Rublo and Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Furlo and Rublo play a game. The table has n piles of coins lying on it, the i-th pile has ai coins. Furlo and Ru

  • LeetCode-322. 零钱兑换2019-04-16 09:53:11

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

  • LeetCode-322.Coin Change2019-04-06 13:39:32

    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 combination of the coins, retu

  • 菲律宾Globe/TM卡最省钱的上网方案2019-03-24 09:37:54

    1:发送SURFALERT ON到8080,这样就关掉了余额扣费的上网方式,防止因为套餐耗尽后疯狂扣话费。 2:用Coins.ph充个15Pisos(也就2元人民币),或则充多点钱都可以。 3:发送GoSURF15到8080,这样就开通了2天有效的100M流量。

  • leetcode 441. 排列硬币(Arranging Coins)2019-03-23 12:50:44

    目录 题目描述: 示例 1: 示例 2: 解法: 题目描述: 你总共有 n 枚硬币,你需要将它们摆成一个阶梯形状,第 k 行就必须正好有 k 枚硬币。 给定一个数字 n,找出可形成完整阶梯行的总行数。 n 是一个非负整数,并且在32位有符号整型的范围内。 示例 1: n = 5 硬币可排列成以下几行: ¤ ¤

  • 找零钱方案的组合数,每种钱无限多,已通过2019-03-13 11:53:38

    1, int change(int amount, vector<int>& coins) { int *dp=new int[amount+1](); dp[0]=1;//相当于用0种硬币兑换0元的方案数,什么都不给,所以一种方案 for(int i=0;i<coins.size();++i) for(int j=0;j<=amount;++j) {

  • HDU-2844-Coins2019-03-03 23:00:07

    链接:https://vjudge.net/problem/HDU-2844#author=CCOA 题意: 给定几种不同面额的硬币若干枚,需要求的用这些硬币可以组成多少种范围在1~m的不同面额的组合。 思路: 多重背包,二进制优化。 代码: #include <iostream>#include <memory.h>#include <vector>#include <map>#include <algo

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

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

ICode9版权所有