Hungry Canadian
具体见代码注释
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
#define maxn 10010
#define inf 0x3f3f3f3f;
int f[maxn][];//f[i][j]表示第i位为字母j的权值
int a[][],n; void scan()
{
int i,j;
scanf("%d",&n);
for(i=;i<;i++)
{
for(j=;j<;j++)
scanf("%d",&a[i][j]);
}
} void solve()
{
for(int i=;i<=n;i++)
{
for(int j=;j<;j++)
{
for(int k=;k<;k++)
{
f[i][j]=min(f[i][j],f[i-][k]+a[k][j]);//f[i-1][k]+a[k][j],第i-1位选k,第i位选j
}
}
}
int ans=inf;
for(int i=;i<;i++)
{
ans=min(ans,f[n][i]);
}
printf("%d\n",ans);
} int main()
{
memset(f,0x3f,sizeof(f));
memset(f[],,sizeof(f[]));
scan();
solve();
return ;
}
Hungry Canadian的更多相关文章
- 恶趣味小游戏 I'm hungry
之前学算法的时候无聊做了个游戏放松放松,现在传到了github以免电脑坏了就永远丢失了... github地址:https://github.com/BenDanChen/IamHungry I am ...
- 【乔布斯05年斯坦福大学毕业典礼上的演讲】——Stay Hungry, Stay Foolish.(转)
Steve Jobs: Commencement Address at Stanford University "Stay Hungry, Stay Foolish." 求知若饥, ...
- [USACO2002][poj1945]Power Hungry Cows(启发式搜索)
Power Hungry CowsTime Limit: 1000MS Memory Limit: 30000K Total Submissions: 4570 Accepted: 1120 Desc ...
- 如何理解Stay hungry,stay foolish?
People know about this words because of Steve Jobs.Me too. Hungry,对知识我们一般不会用hungry,我们会用curious,什么时候我 ...
- Stay Hungry, Stay Foolish--2005斯坦福大学05年毕业演讲
转自http://www.cnblogs.com/daizhj/articles/1493813.html 斯蒂夫•保罗•乔布斯(Steve Paul Jobs,1955年2月24日出生-)是蘋果電腦 ...
- BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 665 Solved: 419 ...
- BZOJ 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛( LIS )
裸的LIS ----------------------------------------------------------------- #include<cstdio> #incl ...
- 『Power Hungry Cows A*启发式搜索』
Power Hungry Cows(POJ 1945) Description FJ的奶牛想要快速计算整数P的幂 (1 <= P <=20,000),它们需要你的帮助.因为计算极大数的幂, ...
- Stay hungry, Stay foolish 的原义
乔布斯在斯坦福大学毕业演讲中说过,他最喜欢的一句话叫做"Stay hungry, Stay foolish". "Stewart和他的人出了好几期<地球产品目录&g ...
随机推荐
- ExtractFileDir 与 ExtractFilePath 的区别
ExtractFileDir 从文件名中获取目录名(文件不在根目录下时取得的值后没有“/”,在根目录时一样,都是盘符,例如“C:/”) ExtractFilePath 从文件名中获取路径名(文件不在根 ...
- 1 matplotlib绘制折线图
from matplotlib import pyplot as plt #设置图形大小 plt.figure(figsize=(20,8),dpi=80) plt.plot(x,y,color=&q ...
- selenium中元素操作之浏览器窗口滚动&网页日期控件操作(js操作)(五)
js的滚动条scrollIntoView() Arguments[] - python与js之间的羁绊 1.移动到元素element对象的“底端”,与当前窗口的“底部”对齐: driver.execu ...
- 一个多进程爬虫下载图片的demo
import os,re import pickle import requests import random import time from bs4 import BeautifulSoup f ...
- 【转载】C#中List集合使用GetRange方法获取指定索引范围内的所有值
在C#的List集合中有时候需要获取指定索引位置范围的元素对象来组成一个新的List集合,此时就可使用到List集合的扩展方法GetRange方法,GetRange方法专门用于获取List集合指定范围 ...
- nodejs中的_filename和_dirname
_filename和_dirname都不是全局对象下的属性,它们都是模块下的 _filename:返回当前模块文件被解析过后的绝对路径,该属性并非全局,而是模块作用域下的 console.log(_f ...
- thymeleaf教程-springboot项目中实现thymeleaf自定义标签
转载: http://www.9191boke.com/466119140.html 91博客网 开始: 在使用thymeleaf的过程中有时候需要公共部分渲染页面,这个时候使用自定义标签实现自 ...
- 实验之RSTP基础配置
STP升级版之RSTP 实验环境 实验拓扑图 实验编址 实验步骤 1.基本配置配置PC端 测试i相通性 2.配置RSTP基本功能在S1-S4上都使用命令stp mode rstp更改生成树模式(因为华 ...
- python关于time几种格式处理方法总结
一.日期时间的表示方法: 时间戳 timestamp: 简介:时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量,是一个float类型 展示形式:1575278720.331 时间 ...
- 【Pet HDU - 4707 】【利用并查集找深度】
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const i ...