spown mj
local function getmjvalnew(key)
local keynew = {}
local sumnval = 0
for _, v in ipairs(key) do
if v<=0 and next(keynew) then
sumnval = sumnval + getmjvalnew(keynew)
keynew = {}
elseif v>0 then
table.insert(keynew, v)
end
end
key = keynew
if not next(key) then return sumnval end
local fval = 0
if key[1] > 2 then
local newarr2 = clone(key)
newarr2[1] = newarr2[1] - 3
local nval = getmjvalnew(newarr2) + 1
if nval > fval then
fval = nval
end
end
if key[2] and key[3] and key[2]>0 and key[3]>0 then
local newarr2 = clone(key)
newarr2[1] = newarr2[1] - 1
newarr2[2] = newarr2[2] - 1
newarr2[3] = newarr2[3] - 1
local nval = getmjvalnew(newarr2) + 1
if nval > fval then
fval = nval
end
end
if #key > 1 then
local newarr2 = clone(key)
table.remove(newarr2, 1)
local nval = getmjvalnew(newarr2)
if nval > fval then
fval = nval
end
end
return sumnval + fval
end
local all = {}
function calcdx(al, n)
if all[n] then return all[n] end
all[n] = getmjvalnew(al)
end
local function calsum(n)
local ret = 0
local al = {}
while(n>0)do
table.insert(al, 1, n%10)
ret = ret + n%10
n = math.floor(n/10)
end
return ret, al
end
function spawnmj(n)
local sum, al = calsum(n)
if sum > 14 or #al > 9 then
return
end
if n > 0 then
calcdx(al, n)
print(n, all[n])
end
if #al == 9 then return end
for _,k in ipairs({1,2,3,4}) do
if sum + k<= 14 then
spawnmj(n*10+k)
end
end
end
spawnmj(0)
dump_t2f(all, "mjdx.lua")
spown mj的更多相关文章
- sicily 1027 MJ, Nowhere to Hide 字符串匹配与排序
1027. MJ, Nowhere to Hide Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description On BBS, th ...
- 【代码笔记】iOS-MBProgressHUD+MJ
一,效果图. 二,工程图. 三,代码. ViewController.m #import "ViewController.h" #import "MBProgressHU ...
- MJ瀑布流学习笔记
1. 如果系统自带的布局的话,是这样: //系统自带的UICollectionViewFlowLayout 而不是UICollectionViewLayout UICollectionViewFlow ...
- MJ刷新控件MJRefreshFooterView上拉之后收不回来的解决办法
修改MJRefreshFooterView.m文件中的这个方法 #pragma mark - 状态相关 #pragma mark 设置状态 - (void)setState:(MJRefreshSta ...
- 使用 MJ 自定义下拉刷新
// // ViewController.m // Refresh // // Created by Apple on 16/7/19. // Copyright © 2016年 mac. All r ...
- 旧Mj下拉刷新 An instance 0xca90200 of class UITableView was deallocated while key value observers were s
An instance 0xca90200 of class UITableView was deallocated while key value observers were still regi ...
- python 3.6 MJ小工具
2017.07.14 update 做了个界面,不需要使用cmd命令行+文件路径的方式来使用了: 链接如下: http://www.cnblogs.com/chenyuebai/p/7150382.h ...
- 看完MJ讲解的单例后的个人总结
1.单例的介绍 单例是iOS常用的开发模式的一种. 2.什么是单例 单例就是一个类只创建一个对象,只分配一次内存空间. 3.单例的应用场景 1)系统的单例: [UIApplication share ...
- Sicily 1027. MJ, Nowhere to Hide
//就是一个简单的字符串配对~~用map来解决很easy #include <iostream> #include <map> #include <string> ...
随机推荐
- eclipse的快捷键(常用)
1. Ctrl+O 显示类中方法和属性的大纲,能快速定位类的方法和属性,在查找Bug时非常有用. 2. Ctrl+M 窗口最大化和还原,用户在窗口中进行操作时,总会觉得当前窗口小(尤其在编写代码时), ...
- 基于TCP的通信程序设计
套接字(Socket)是一种跨主机进程之间的双向通信接口,每个打开的套接字都可以通过一个套接字描述符来描述,因此可以使用低级文件编程库操作套接字. TCP是一中面向连接的网络传输控制协议.它每发送一个 ...
- HDU 1247 Hat’s Words(字典树变形)
题目链接:pid=1247" target="_blank">http://acm.hdu.edu.cn/showproblem.php? pid=1247 Pro ...
- Package template (html/template) ... Types HTML, JS, URL, and others from content.go can carry safe content that is exempted from escaping. ... (*Template) Funcs ..
https://godoc.org/text/template GoDoc Home About Go: text/templateIndex | Examples | Files | Directo ...
- Kotlin基本语法笔记2之类型检测及自动类型转换、循环
类型检测及自动类型转换 is运算符用于检测一个表达式是否为某类型的一个实例检测出为某类型后,检测后的分支中可以直接当作该类型使用,无需显示转换 fun getStringLength(obj: Any ...
- No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).错误解决方法
targets ->build setting 下的 Build Active Architecture Only 设置 NO 就可以.
- spawn类参数command详解
我们主要来看spawn类它的构造方法参数主要有command,从字面上就是指spawn类的子程序用来执行的子程序,也就是系统所能够执行的相应的命令,对于command这个参数,我们是以字符串的方式给出 ...
- ABAP OLE常用方法和属性
转自 http://www.cnblogs.com/eric0701/p/5213694.htmlSAP EXCEL OLE常用方法和属性 附加网上找到的比较好的源代码示例一份 1.ole中如何保存和 ...
- wireshark 学习 1
wireshark 调试WiFi 安装之后的启动脚步. #!/bin/bash iw dev mon0 del iw dev wlp3s0 interface add mon0 type monito ...
- 使用php ffmpeg处理视频
工作中遇到video加载视频的问题,但是视频封面在手机上无法取到视频的第一帧,video标签无法在手机上取到第一帧,经过几天的研究于搜索终于找到比较好用的办法,就是php ffmped 插件,该插件的 ...