(Last) Mua(III) - Full Interpreter
题目描述
[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=279&page=show_problem&problem=3854
[PDF](https://uva.onlinejudge.org/external/124/p12423.pdf)
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12423/f55be60b00139097a5fbf227b5e529f2a51e9fb3.png)
输入输出格式
输入格式
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12423/72ab43d4c4e7d6bfe0f5d6b22238f796321ecdc6.png)
输出格式
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12423/73f29ddeae02dfbdd76c5ce0f47165fe9f7815e4.png)
输入输出样例
输入样例 #1
-- PROGRAM: Eight-Queen problem solver in Mini-Lua
function dfs(d)
if d == n then
cnt = cnt + 1
else
for i = 1, n do
if (not vis[i]) and (not vis2[d-i]) and (not vis3[d+i]) then
vis[i] = true
vis2[d-i] = true
vis3[d+i] = true
dfs(d+1)
vis[i] = nil
vis2[d-i] = nil
vis3[d+i] = nil
end
end
end
end
vis = {}
vis2 = {}
vis3 = {}
cnt = 0
n = 8
dfs(0)
print(cnt)
-- PROGRAM: Scoping and Visibility rules
x = 10
do
local x = x
print(x)
x = x+1
do
local x = x+1
print(x)
end
print(x)
end
print(x)
输出样例 #1
Program 1:
92
Program 2:
10
12
11
10