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> ...
随机推荐
- Sass编译css/Grunt压缩文件
Sass安装(mac) $ sudo gem install sass scss编译成css文件 $ sass ui.scss ui.css CLI安装 $ npm install -g grunt- ...
- 脱了裤子放屁之std::string
一个天天跟c#奋斗的苦逼c++程序猿 改自己曾经代码的时候发现有例如以下几行. char szPath[MAX_PATH] = {0}; GetModuleFileNameA(NULL,szPath, ...
- 【BZOJ4800】[Ceoi2015]Ice Hockey World Championship Meet in the Middle
[BZOJ4800][Ceoi2015]Ice Hockey World Championship Description 有n个物品,m块钱,给定每个物品的价格,求买物品的方案数. Input 第一 ...
- EasyPusher:基于live555的DarwinInjector实现的RTSP直播推送程序
先简单介绍一下EasyPusher的功能,后面再对具体内部架构做介绍: EasyPusher:https://github.com/EasyDarwin/EasyPusher EasyPusher是什 ...
- 2018.11.23-day27 面向对象(大总结)
1. 2个内置函数 2.反射 3.内置方法 4.面向对象大总结 思维导图地址:https://www.processon.com/view/link/5bfcfd62e4b0ef094cbf04a7 ...
- wepy开发
工欲善其事必先利其器 ide安装.配置] https://tencent.github.io/wepy/document.html VS Code 1. 在 Code 里先安装 Vue 的语法高亮 ...
- yuicompressor
yui/yuicompressor: YUI Compressor https://github.com/yui/yuicompressor YUI Compressor 详细介绍 YUI ...
- accessor mothod mutator mothod 更改器方法 访问器方法 类的方法可以访问类的任何一个对象的私有域!
LocalDate.plusDate String.toUpperCase GregorianCalendar.add import java.time.*; public class Calenda ...
- The basic principle of test case 修改引擎
The basic principle of test case evaluation is that output resulting from running a test case is com ...
- java后台判断发布的图片是否存在
x现在已知一个固定格式的图片,判断图片是否存在例如,http://127.0.0.1/image/201709091300.jpg import java.net.URL;import java.ne ...