hdu 3732 Ahui Writes Word】的更多相关文章

HDU 3732 Ahui Writes Word(多重背包) http://acm.hdu.edu.cn/showproblem.php? pid=3732 题意: 初始有N个物品, 每一个物品有cost[i]花费和val[i]价值, 你有m元钱, 如今问你最多能买多少总价值的物品? 当中N<=10W, m<=1W. 且cost[i]和val[i]都在[0,10]范围. 分析: 本题初看直接用01背包来做是直观的想法. 可是考虑到01背包的复杂度为O(N*m), 这么大的复杂度肯定不行. 然…
这是一道背包题,当你题读完了的时候,你会觉得这道题明明就是01背包的完全版吗! no no no no no no  no no  no no no~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ~~~~~~~~~~~~~~~~~~~~~ 对!不是,是,还是不是,是~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 好吧,这是一道01背包题,但按01背…
题目大意:有n个单词,m的耐心,每个单词有一定的价值,以及学习这个单词所消耗的耐心,耐心消耗完则,无法学习.问能学到的单词的最大价值为多少. 题目思路:很明显的01背包,但如果按常规的方法解决时间复杂度O(n)=1e9,会超时.因为每个单词的价值和代价都不超过10,所以可以用二维数组G[V][W],记录价值为V,代价为W的单词的个数,并用多重背包的思路解决. #include<cstdio> #include<stdio.h> #include<cstdlib> #in…
之前在做背包的题目时看到了这道题,一看,大喜,这不是裸裸的01背包吗!!  然后华丽丽的超时,相信很多人也和我一样没有考虑到数据量的大小. 时隔多日,回过头来看这道题,依旧毫无头绪....不过相比之前,我看到了更多细节. 来看题目吧,可能有100000个单词,然后只有1000ms,但看包的大小,有10000,这样只能允许nlog(n)的算法,还有,每个单词的价值和花费都很小(不大于十),如果不考虑单词的不同,只考虑价值和花费只有最多100种东西,但如果把这些按多重背包的方法来计算依旧会超时,很容…
// N个物品 放进容量为C的背包里面 要求价值最大// 一看 第一反应是0 1背包 不过 N=100000 C=10000// 注意到 v,c在 10以内// 那么 最多就100种组合了 然后就转化为 多重背包了// dp#include <iostream> #include <string> #include <map> #include <algorithm> #include <queue> #include <math.h>…
初看01背包,果断TLE.是因为n和C都比较大.但是vi和ci却很小,转化为多重背包. #include <cstdio> #include <cstring> ][]; ]; int n, C; int max(int a, int b) { return a>b ? a:b; } void ZeroOnePack(int v, int c) { for (int i=C; i>=c; --i) dp[i] = max(dp[i-c]+v, dp[i]); } voi…
Ahui Writes Word Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2356 Accepted Submission(s): 863 Problem Description We all know that English is very important, so Ahui strive for this in order t…
#include<stdio.h> #include<string.h> int n,m,dp[10001]; int max(int a,int b) {  return a>b?a:b; } void yi(int val,int co) {  int i;  for(i=m;i>=co;i--)   dp[i]=max(dp[i],dp[i-co]+val); } void duo(int val,int co) {  int i;  for(i=co;i<…
Dividing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 18190    Accepted Submission(s): 5080 Problem Description Marsha and Bill own a collection of marbles. They want to split the collection…
Ahui Writes Word Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2853    Accepted Submission(s): 1018 Problem Description We all know that English is very important, so Ahui strive for this in o…
Ahui Writes Word Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2915    Accepted Submission(s): 1036 Problem Description We all know that English is very important, so Ahui strive for this in o…
void solve(int v,int w,int c){    int count=0;    for(int k=1;k<=c;k<<=1)    {        val[count]=k*v;        size[count++]=k*w;        c-=k;        }    if(c>0)    {        val[count]=c*v;        size[count++]=c*w;    }    for(int i=0;i<cou…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 题意:输入一个字典,然后再输入若干单词(每行中,1 <= 单词数 <= 100,并且每个单词在字典中保证是唯一的),用XXXXXX结尾来表示字典的结束.接着输入一个单词word(1 <= 字母个数 <= 6),每个单词你都需要在字典中找出所有可以用word的字母重排后得到的单词,并按照字典序从小到大的顺序在一行中输出:如果不存在,则输出“NOT A VALID WORD”.注意:…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 字符串简单题: stl水过 如下: #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<map> #include<set>…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 找单词 #include <iostream> #include <string> #include <map> #include <algorithm> using namespace std; map<string, string> str; string s, t; int main() { while(cin >> s &a…
http://acm.hdu.edu.cn/showproblem.php?pid=1113 给定一个字典,然后每次输入一个字符串问字典中是否有单词与给定的字符串的所有字母一样(顺序可以打乱),按字典序输出字典中的原字符串. 我开始是直接用了 sort, 用一个结构体记录了所有字符串,和相应下标,输出的时候在用了冒泡排序. #include <iostream> #include <cstdio> #include <cmath> #include <vector…
http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in th…
Problem Description In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in the answer it is necessary to unscramble four wor…
1.在使用mp[key]的时候它会去找键值为key的项,假设没有,他会自己主动加入一个key的项,再把value赋值为对应的初始值(value是int的话赋值为0,string的话赋值为空).所以假设是插入的话能够用insert.假设是查找的话能够使用find.这样能够节省开销. 查找的时间复杂度为O(logn) watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d…
1.POJ 1733 Parity game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5744   Accepted: 2233 Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You cho…
HDU 1814 Peaceful Commission / HIT 1917 Peaceful Commission /CJOJ 1288 和平委员会(2-sat模板题) Description The Public Peace Commission should be legislated in Parliament of The Democratic Republic of Byteland according to The Very Important Law. Unfortunatel…
并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could encode it using the following method: 1. Each sub-string containing k same characters should be encoded to "kX" where "X" is the only c…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1814 Problem Description The Public Peace Commission should be legislated in Parliament of The Democratic Republic of Byteland according to The Very Important Law. Unfortunately one of the obstacles is t…
一.NPOI 简介: NPOI is the .NET version of POI Java project. With NPOI, you can read/write Office 2003/2007 files very easily. 官网地址: https://github.com/tonyqus/npoi http://npoi.codeplex.com/ 二.EPPlus 简介: EPPlus is a .net library that reads and writes Exc…
link: http://www.cnblogs.com/jacktang/p/4493760.html 一.NPOI 简介:NPOI is the .NET version of POI Java project. With NPOI, you can read/write Office 2003/2007 files very easily. 官网地址:https://github.com/tonyqus/npoihttp://npoi.codeplex.com/ 二.EPPlus 简介:E…
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201…
Intelligent IME Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4776    Accepted Submission(s): 2227 Problem Description We all use cell phone today. And we must be familiar with the intelligen…
题目链接:hdu 2177 这题不是普通的 Nim 博弈,我想它应该是另一种博弈吧,于是便推 sg 函数打了个 20*20 的表来看,为了方便看一些,我用颜色作了标记,打表代码如下: #include<cstdio> #include<cstring> #include<string> #include<map> #include<algorithm> #include<windows.h> using namespace std;…
GCD is Funny 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5902 Description Alex has invented a new game for fun. There are n integers at a board and he performs the following moves repeatedly: He chooses three numbers a, b and c written at the boa…
Description DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog. But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer…