博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4433 locker
阅读量:7117 次
发布时间:2019-06-28

本文共 1349 字,大约阅读时间需要 4 分钟。

题意:A password locker with N digits, each digit can be rotated to 0-9 circularly.

        You can rotate 1-3 consecutive digits up or down in one step.
        For examples:

  •         567890 -> 567901 (by rotating the last 3 digits up)
  •         000000 -> 000900 (by rotating the 4th digit down)
  •         Given the current state and the secret password, what is the minimum amount of steps
  •         you have to rotate the locker in order to get from current state to the secret password?
#include 
#include
#include
#include
#define maxn 1100 #define inf 1000000 using namespace std; char s1[maxn]; char s2[maxn]; int a[maxn]; int b[maxn]; int up[12][12]; int down[12][12]; int dp[maxn][12][12]; int n; void init() { int i,j; for(i=0;i<=9;i++) { for(j=0;j<=9;j++) { up[i][j]=j>=i?j-i:10+(j-i); down[i][j]=j<=i?i-j:10+i-j; } } } int main() { init(); int i,j,k; int ii,jj; while(~scanf("%s %s",&s1, &s2)) { n = strlen(s1); for(i=0;i<=n+3;i++) { for(j=0;j<=9;j++) { for(k=0;k<=9;k++) { dp[i][j][k]=inf; } } } for(i=0; i

 

转载于:https://www.cnblogs.com/dream-wind/archive/2012/10/28/2743848.html

你可能感兴趣的文章
将敏捷应用于工业机械开发
查看>>
有赞HBase技术实践:读流程解析与优化
查看>>
微软最具价值技术专家:我的16年软件开发经验总结
查看>>
腾讯云+未来高峰对话:智能+时代的创新与探索
查看>>
C# 8中的默认接口方法
查看>>
实现TeX的算法:回首编程技术的过去三十年
查看>>
京东构建了全球最大的Kubernetes集群,没有之一
查看>>
Facebook是如何缩短iOS应用启动时间的
查看>>
又拍云CDN再出力作,三驾马车为视频护航
查看>>
Java RESTful Web Service实战
查看>>
全球首届APMCon,带你给“应用性能”把把脉
查看>>
详解分布式系统本质:“分治”和“冗余”
查看>>
谈谈常见H5制作方法——视频与CSS3
查看>>
[译]Yarn:一个新的JavaScript包管理器
查看>>
用VS2015开发Linux程序详细教程-配置篇
查看>>
实用的IT类网站及工具大集合
查看>>
tomcat的servlet读取请求参数
查看>>
CentOS下jenkins安装与配置
查看>>
首屏渐进式渲染设想
查看>>
web缓存机制
查看>>