2013年9月16日

HDU1575Tr A(矩阵相乘与快速幂)

摘要: Tr A hdu1575就是一个快速幂的应用:只要知道怎么求矩阵相乘!!(比赛就知道会超时,就是没想到快速幂!!!) 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 __int64 a[15][15],b[15][15],c[15][15]; 7 int n; 8 int main() 9 {10 int t,i,j,m,k,d;11 __int64 sum;12 scanf("%d",&t);13 while(t--)14 {15 scanf("%... 阅读全文
posted @ 2013-09-16 22:17 ~~碾压机 阅读(236) 评论(0) 推荐(0) 编辑
2013年9月11日

HDU4430 Yukari's Birthday(枚举+二分)

摘要: Yukari's Birthday HDU4430就是枚举+二分:注意处理怎样判断溢出。。。(因为题目只要10^12)先前还以为要用到快速幂和等比数列的快速求和(但肯定会超__int64)而且这样判断会超时的。。。还有题目中的And it's optional to place at most one candle at the center of the cake. (中间的蜡烛可有可无)还有观察数据就知道:因为n最大10^12,r最多枚举到40,然后二分k的结果,看是否有符合条件的k存在。 1 #include 2 #include 3 #include 4 using n 阅读全文
posted @ 2013-09-11 11:04 ~~碾压机 阅读(181) 评论(0) 推荐(0) 编辑
2013年9月6日

找出最优木棍序列(简单的递推。。。但是没做出来)

摘要: 假设有一个木棍序列N,其长度分别为a1,a2,…aN。定义该序列的质量为F(N)= |a-b|+|b-c|+|c-d|。有个工厂老板找一批木棍,先后去了几个木材厂,都能够提供m个木棍。于是他就想从这么多木棍中找出一个木棍序列N,使得F(N)最小。但让他有个要求:1 每个厂家只取一个木棍2 每个厂家都有一个编号1-n,取木棍的顺序是按厂家编号进行。输入:包含多个测试用例,对每个测试用例,第一行包含两个整数n, m (1 =查找值”的第一个元素的位置摘自:http://blog.csdn.net/niushuai666/article/details/6734403 1 #include 2 #i 阅读全文
posted @ 2013-09-06 14:53 ~~碾压机 阅读(220) 评论(0) 推荐(0) 编辑
2013年9月1日

Constructing Roads In JGShining's Kingdom(HDU1025)(LCS序列的变行)

摘要: Constructing Roads In JGShining's Kingdom HDU1025题目主要理解要用LCS进行求解!并且一般的求法会超时!!要用二分!!!最后蛋疼的是输出格式的注意(直接报错误!!!) 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int a[500005],dp[500005]; 7 int main() 8 { 9 int n,i,a1,b1,len,j,d=0,left,right,mid;10 while(scanf("%d",& 阅读全文
posted @ 2013-09-01 19:39 ~~碾压机 阅读(173) 评论(0) 推荐(0) 编辑
2013年8月31日

Happy Programming Contest(ZOJ3703)(01背包+路径储存)

摘要: Happy Programming Contest ZOJ3703老实说:题目意思没看懂。。。(希望路过的大神指点)最后那个the total penalty time是什么意思啊!!!还是学到点东西的。。。解题的关键在于:要控制最后所用的时间最少,所以在程序的最开始应该先将输入的各种题目 以时间升序排列, 然后就可以保证每次都以时间小的优先选, 这样就可以保证最后相同的吸引值和解题数的情况下所花的时间最少。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 struct P... 阅读全文
posted @ 2013-08-31 16:11 ~~碾压机 阅读(309) 评论(0) 推荐(0) 编辑
2013年8月30日

I am Nexus Master!(虽然只是个模拟题。。。但仍想了很久!)

摘要: I am Nexus Master! The 13th Zhejiang University Programming Contest参见:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29137题意就理解错了!!!之后乱搞就也错了!!!Current Server Time:2013-08-30 23:29:55I am Nexus Master!Time Limit:2000msMemory Limit:65536KBThis problem will be judged on ZJU. Original ID:370464-bit int 阅读全文
posted @ 2013-08-30 23:35 ~~碾压机 阅读(367) 评论(1) 推荐(0) 编辑

Robberies(HDU2955):01背包+概率转换问题(思维转换)

摘要: Robberies HDU2955因为题目涉及求浮点数的计算:则不能从正面使用01背包求解。。。为了能够使用01背包!从唯一的整数(抢到的钱下手)。。。之后就是概率的问题:题目只是给出被抓的几率,如果同时抢两家银行的话,那么被抓的概率是:(1-一家不被抓的概率*另一家不被抓的概率)才是同时抢两家被抓的概率!最后和题目给出的概率比较取较大值。。。那么赋初值的时候dp[0]=1。注意:不要误以为精度只有两位。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 double n,b[105]; 7 double 阅读全文
posted @ 2013-08-30 21:38 ~~碾压机 阅读(204) 评论(0) 推荐(0) 编辑

Big Event in HDU(HDU1171)可用背包和母函数求解

摘要: Big Event in HDU HDU1171就是求一个简单的背包:题意:就是给出一系列数,求把他们尽可能分成均匀的两堆如:2 10 1 20 1 结果是:20 10。才最均匀!三种解法:多重背包的优化与否:(1031MS) 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int dp[250005]; 7 int a[55],b[55]; 8 int main() 9 {10 int n,s,i,j,k;11 while(scanf("%d",&n)!=EOF)12 {13 阅读全文
posted @ 2013-08-30 17:06 ~~碾压机 阅读(172) 评论(0) 推荐(0) 编辑

Piggy-Bank(HDU 1114)背包的一些基本变形

摘要: Piggy-Bank HDU 1114初始化的细节问题:因为要求恰好装满!!所以初始化要注意:初始化时除了F[0]为0,其它F[1..V]均设为−∞。又这个题目是求最小价值:则就是初始化时除了F[0]为0,其它F[1..V]均设为∞。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int inf=1000005; 7 int a[505],b[505],dp[10005]; 8 int main() 9 {10 int t,n,n1,m,i,j;11 scanf("%d" 阅读全文
posted @ 2013-08-30 15:52 ~~碾压机 阅读(147) 评论(0) 推荐(0) 编辑
2013年8月29日

Coins(HDU 2844):一个会超时的多重背包

摘要: Coins HDU 2844不能用最基础的多重背包模板:会超时的!!!之后看了二进制优化了的多重背包。就是把多重转变成01背包:具体思路见:http://www.cnblogs.com/tt123/p/3280521.html 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int dp[100005],a1[100005],a[105],b[105]; 7 int main() 8 { 9 int n,m,i,j,k,s,cout1;10 while(scanf("%d%d",&am 阅读全文
posted @ 2013-08-29 23:44 ~~碾压机 阅读(238) 评论(0) 推荐(0) 编辑