POJ 1260
来源:互联网 发布:索福瑞实时数据 编辑:程序博客网 时间:2024/05/16 07:33
#include<iostream>#include<fstream>#include<cstdlib>using namespace std;//#define DEBUG/* 244K0MS */static const int MAX = 101;static int count[MAX];static int price[MAX];static int presum[MAX];static int n;static int f[MAX];int main(){#ifdef DEBUGfstream cin("G:\\book\\algorithms\\acm\\Debug\\dat.txt");#endifint t;cin >> t;while (t-- > 0){cin >> n;int i, j;for (i = 1; i <= n; i++){cin >> count[i] >> price[i];presum[i] = presum[i - 1] + count[i];}f[1] = (count[1] + 10) * price[1];for (i = 2; i <= n; i++){int min = (presum[i] + 10) * price[i];for (j = 1; j < i; j++) /* 列举全部可能性 找到最小值 */{int tmp = (presum[i] - presum[j] + 10) * price[i] + f[j];if (tmp < min)min = tmp;}f[i] = min;}printf("%d\n", f[n]);}return 0;}
POJ1260
对于第i项,列举其全部的可能组合,进行比较找到其中的最小值,就是解。题目中的输入数据已经做了部分简化,
1.输入数据按照price的升序进行排列
2.购买时的替代是单方向的
从本质上讲这一题还是一个“划分”的变形。找到划分方法也就找到了动态转移方程。
- poj 1260
- POJ 1260
- POJ 1260
- poj-1260
- poj-1260
- poj 1260
- poj 1260
- POJ 1260
- poj 1260
- poj 1260 Pearls
- POJ 1260 Pearls
- POJ 1260 Pearls DP
- Poj 1260 Pearls
- POJ 1260 Pearls
- POJ 1260 dp
- poj 1260 pearls
- poj-1260-Pearls-dp
- POJ 1260 Pearls
- ubuntu 桌面學習
- 用vc写一款网络电视程序
- POJ3244(工科数学分析)
- Ubuntu用tar备份与恢复方法
- 黑皮的蛋糕
- POJ 1260
- 【转载内容】打造高效的产品团队
- 剑指offer面试题36:数组中的逆序对
- 26可滚动的结果集
- 类加载及对象 成员变量初始化顺序
- 动态规划入门——最大子矩阵
- JZ2440 编译U-boot1.1.6 undefined reference to ‘raise’
- C++字符串的使用学习笔记01
- C#反射 获取程序集信息和通过类名创建类实例