Divide two integers without using multiplication, division and mod operator.常常出现大的负数,无法用abs()转换成正数的情况class Solution{private: vector f;public: in...
分类:
其他好文 时间:
2014-08-23 17:43:11
阅读次数:
215
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-08-20 11:57:22
阅读次数:
198
题目大意:
在一串数字中取出除了两端的两个数字,求出最小的代价,代价就是每取出一个数,都要加上它与它相邻的两个数的积。
思路分析:
状态方程 :dp [i] [j] 是区间 [i , j] 已经全部取完,只剩下 i j所剩的最小代价。
状态转移 :dp [i][j] = min (dp [i][j], dp[i][k] + dp[k] [j] + a[i]*a[k]*a[j]) ....
分类:
其他好文 时间:
2014-08-16 17:11:00
阅读次数:
230
1 /* 2 题意:矩阵相乘的最少的步数 3 dp[i][j]=min(dp[i][j], dp[i][k]+dp[k+1][j]+num[i-1]*num[k]*num[j]); 4 表示的是第i个矩阵到第j个矩阵相乘的最少步数 5 sign[i][j]表示的是第...
分类:
其他好文 时间:
2014-08-15 23:46:59
阅读次数:
269
Problem Description
Teacher Mai has a multiplication table in base p.
For example, the following is a multiplication table in base 4:
* 0 1 2 3
0 00 00 00 00
1 00 01 02 03
2 00 02 10 12
3...
分类:
其他好文 时间:
2014-08-15 19:44:19
阅读次数:
278
Problem Description
Teacher Mai has a multiplication table in base p.
For example, the following is a multiplication table in base 4:
* 0 1 2 3
0 00 00 00 00
1 00 01 02 03
2 00 02 10 12
3...
分类:
其他好文 时间:
2014-08-15 09:33:37
阅读次数:
190
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4951
题意:给一个P进制的乘法表,行和列分别代表0~p-1,第i行第j*2+1和第j*2+2列代表的是第i行的数x和第j列的数的乘积,不过这个乘法表被人弄乱了,原来的0~p-1被映射到了一个新的0~p-1的permutation(以前在CF上看见的permutation表示1~P,所以稍有迷茫),分别代...
分类:
其他好文 时间:
2014-08-14 20:47:10
阅读次数:
187
Time Limit:1000MSMemory Limit:10000KTotal Submissions:3239Accepted:1459Consider polynomials whose coefficients are 0 and 1. Addition of two polynomial...
分类:
其他好文 时间:
2014-08-13 12:58:06
阅读次数:
247
题目大意:
给出矩阵a,b,c。验证a*b是否等于c。
解题思路:
三次方复杂度的算法, 正常情况下是过不了的。但是输入优化后可以过。
再有就是随机验证。
第二种没有啥意思,就记录一下输入优化好了~
下面是代码:
#include
#include
#include
#include
#include
#include
#include
#inc...
分类:
其他好文 时间:
2014-08-12 19:02:24
阅读次数:
278