当前位置: 首页 > news >正文

江苏营销型网站建设公司/seo优化顾问服务阿亮

江苏营销型网站建设公司,seo优化顾问服务阿亮,腾讯云服务器可以干嘛,wordpress拼音tag插件题目传送门 题意:给一串跳舞的动作,至少一只脚落到指定的位置,不同的走法有不同的体力消耗,问最小体力消费多少分析:dp[i][j][k] 表示前i个动作,当前状态(j, k)的最小消费,状态转移方程&#xf…

 

题目传送门

题意:给一串跳舞的动作,至少一只脚落到指定的位置,不同的走法有不同的体力消耗,问最小体力消费多少
分析:dp[i][j][k] 表示前i个动作,当前状态(j, k)的最小消费,状态转移方程:(a[i], k) <- min (a[i-1], k) + cost以及(a[i-1], a[i]) <- min (a[i-1], k) + cost, (k, a[i])和(a[i], a[i-1])情况类似,最后再去最小值就行了

收获:四个状态转移方向

 

代码:

/************************************************* Author        :Running_Time* Created Time  :2015-8-15 14:31:31* File Name     :UVA_1291.cpp************************************************/#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e4 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int a[MAXN];
int dp[MAXN][5][5];int cal(int x, int y)   {int ret;if (x == y) ret = 1;else    {if (y == 0)    ret = 2;else    {if (abs (x - y) == 2)   {ret = 4;}else    ret = 3;}}return ret;
}int main(void)    {     //UVA 1291 Dance Dance Revolutionint n = 0;while (scanf ("%d", &a[++n]) == 1)  {if (a[1] == 0)  break;while (a[n] != 0)   {scanf ("%d", &a[++n]);}n--;memset (dp, INF, sizeof (dp));dp[1][a[1]][0] = (a[1] == 0 ? 1 : 2);dp[1][0][a[1]] = (a[1] == 0 ? 1 : 2);for (int i=2; i<=n; ++i)    {for (int j=0; j<=4; ++j)    {int c1 = cal (a[i], j);int c2 = cal (a[i], a[i-1]);int x = a[i], y = a[i-1];dp[i][x][y] = min (dp[i][x][y], dp[i-1][j][y] + c1);dp[i][j][x] = min (dp[i][j][x], dp[i-1][j][y] + c2);dp[i][y][x] = min (dp[i][y][x], dp[i-1][y][j] + c1);dp[i][x][j] = min (dp[i][x][j], dp[i-1][y][j] + c2);}}int ans = INF;for (int i=0; i<=4; ++i)    {ans = min (ans, min (dp[n][i][a[n]], dp[n][a[n]][i]));}printf ("%d\n", ans);   n = 0;}return 0;
}

  

转载于:https://www.cnblogs.com/Running-Time/p/4732542.html

http://www.jmfq.cn/news/5298229.html

相关文章:

  • wordpress数据查询系统/seo免费优化软件
  • 网页隐藏网站代码/淘宝关键词
  • 做网站准备材料/sem是什么岗位
  • 有个网站专做品牌 而且价格便宜/百度搜索资源平台
  • 怎么做.com的网站/百度关键字搜索排名
  • 设计说明翻译/网站内链优化
  • 做棋牌网站犯法吗/推广搜索引擎
  • 免费的网站模板哪里有/搜索引擎优化公司
  • 做网站能赚到钱吗/手机怎么建自己的网站
  • 东莞网站建设设/站长网站优化公司
  • wordpress首页api幻灯片/内部优化
  • wordpress自然志下载/seo研究协会网
  • 协会网站建设的优势/广州市口碑seo推广外包
  • 购物网站那个信用好又便宜/网站推广seo设置
  • 免费的求职简历模板网站/it培训机构排名
  • 武汉做网站网络公司/成都抖音seo
  • 公司网站现状/seo168小视频
  • 厦门电子网站建设/经典网络营销案例
  • 网站产品图怎么做/seo网站平台
  • 英文成品网站模板下载/东莞seo外包公司哪家好
  • 专业做网站的团队/竞价恶意点击器
  • 邵阳网站建设多少钱/seo关键词优化经验技巧
  • 哪些网站用c 做的/站长工具视频
  • 做百度网站每年的费用多少钱/廊坊seo优化排名
  • 赌博网站做代理微信群卖房卡/有创意的营销策划案例
  • wordpress建站方法/seo顾问服务福建
  • 网页设计实验报告步骤/appstore关键词优化
  • 郑州电商公司排名前十有哪些/seo常用方法
  • 沈阳制作网站的公司有哪些/如何建立个人网址
  • 陕西省建设教育培训中心网站/云盘搜索