区间DP基础题
只贴代码
#include
#include
#include
#include
using namespace std;
#define maxn 0xfffffff
int main()
{
int n,i,j,k,l;
int num[1111],dp[1111][1111];
scanf("%d",&n);
...
分类:
其他好文 时间:
2015-08-04 21:08:31
阅读次数:
138
题目链接:http://poj.org/problem?id=1651题意:初使ans=0,每次消去一个值,位置在pos(pos!=1 && pos !=n)
同时ans+=a[pos-1]*a[pos]*a[pos+1],一直消元素直到最后剩余2个,求方案最小的ans是多少?代码:#include
#include
#include
#inc...
分类:
其他好文 时间:
2015-08-03 06:44:49
阅读次数:
283
此题可以转化为最优矩阵链乘的形式,d(i, j)表示区间[i, j]所能得到的最小权值。枚举最后一个拿走的数a[k],状态转移方程为d(i, j) = min{ d(i, k) + d(k, j) + a[i] * a[k] * a[j] } 1 #include 2 #include 3 #i.....
分类:
其他好文 时间:
2015-08-03 00:47:56
阅读次数:
161
hdu 3338 Kakuro ExtensionDescription
If you solved problem like this, forget it.Because you need to use a completely different algorithm to solve the following one.
Kakuro puzzle is played on a grid...
分类:
其他好文 时间:
2015-08-02 21:36:14
阅读次数:
143
点击打开链接
这是一道字符串模拟题,可以用来锻炼代码能力吧。
题意很简单给定一个5*5的迷宫,其中有一个空格,每次操作都是让空格进行移动,输出一系列操作之后的迷宫。
int main()
{
int t=0;
while(gets(puzzle[0]))
{
int x,y;
if(puzzle[0][0]=='Z') break;
from(i,1,5)
gets(puzzle[i]);
from(...
分类:
其他好文 时间:
2015-07-29 06:31:05
阅读次数:
103
题目链接:http://poj.org/problem?id=3678思路分析:该问题要求判断是否能给定每一个布尔变量一个值,使布尔变量满足某些逻辑条件;需要根据逻辑条件来进行点与点的连接:假设两个变量为a与b,2 * a表示a的值为0的点,2 * a + 1表示a的值为1的点,则可以根据逻辑条件给...
分类:
其他好文 时间:
2015-07-28 12:32:29
阅读次数:
99
The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, eac...
分类:
其他好文 时间:
2015-07-26 20:30:06
阅读次数:
106
3.4 In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts ...
分类:
其他好文 时间:
2015-07-26 12:25:22
阅读次数:
122
DescriptionThe 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding...
分类:
其他好文 时间:
2015-07-23 15:25:26
阅读次数:
141
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 34106 Accepted Submission(s): 12255
Problem Description
lcy gives a hard puzzle to fe...
分类:
其他好文 时间:
2015-07-20 10:55:38
阅读次数:
122