27,582
社区成员




--电脑很慢,用了3:46"
;WITH CTE AS
(
SELECT TOP 33 ID=ROW_NUMBER() OVER (ORDER BY GETDATE()) FROM syscolumns
)
,CTE2 AS
(
SELECT ID,CAST(ID AS VARCHAR(8000)) AS COP,LVL=1 FROM CTE
UNION ALL
SELECT CTE.ID,COP=COP+','+RTRIM(CTE.ID),LVL+1 FROM CTE,CTE2 WHERE CTE.ID<CTE2.ID AND LVL<6
)
SELECT ROW_NUMBER() OVER (ORDER BY GETDATE()),COP FROM CTE2 WHERE LVL=6
/*
COP
-------------------- ---------------------------------------------------------
1 33,32,31,30,29,1
2 33,32,31,30,29,2
3 33,32,31,30,29,3
4 33,32,31,30,29,4
5 33,32,31,30,29,5
6 33,32,31,30,29,6
..........
1107564 7,6,5,4,2,1
1107565 7,6,5,3,2,1
1107566 7,6,4,3,2,1
1107567 7,5,4,3,2,1
1107568 6,5,4,3,2,1
(1107568 row(s) affected)
*/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script>
function oo()
{
var str =
"1," +
"2," +
"4," +
"8," +
"16," +
"32," +
"64," +
"128," +
"256," +
"512," +
"1024," +
"2048," +
"4096," +
"8192," +
"16384," +
"32768," +
"65536," +
"131072," +
"262144," +
"524288," +
"1048576," +
"2097152," +
"4194304," +
"8388608," +
"16777216," +
"33554432," +
"67108864," +
"134217728," +
"268435456," +
"536870912," +
"1073741824"/* +
"2147483648," +
"4294967296"*/;
var a = str.split(",");
var result = new Array(736281);
var resultStr = "";
var i = 0;
alert ("good");
for (var x6 = 30/*32*/; x6 >= 5; x6--)
for (var x5 = x6 - 1; x5 >= 4; x5--)
for (var x4 = x5 - 1; x4 >= 3; x4--)
for (var x3 = x4 - 1; x3 >= 2; x3--)
for (var x2 = x3 - 1; x2 >= 1; x2--)
for (var x1 = x2 - 1; x1 >= 0; x1--, i++)
{
result[i] = a[x6] | a[x5] | a[x4] | a[x3] | a[x2] | a[x1];
}
document.write ("result number: " + i + "<br>");
document.write ("<table>");
for (var i = 0; i < result.length; i += 1000)
{
document.write ("<tr><td>" + result[i] + "</td></tr>");
}
document.write ("</table>");
alert ("good");
}
</script>
</head>
<body>
<SCRIPT>oo()</SCRIPT>
</body>
</html>
select top 33 identity(int,1,1) id into #t from sys.objects
select a.id id1,b.id id2,c.id id3,d.id id4,e.id id5,f.id id6
from #t a cross join #t b cross join #t c cross join #t d cross join #t e cross join #t f
where a.id<>b.id and a.id<>c.id and a.id<>d.id and a.id<>e.id and a.id<>f.id
and b.id<>c.id and b.id<>d.id and b.id<>e.id and b.id<>f.id
and c.id<>d.id and c.id<>e.id and c.id<>f.id
and d.id<>e.id and d.id<>f.id
and e.id<>f.id
/*结果
id1,id2,id3,id4,id5,id6
-----------------------
4 6 5 2 3 1
4 7 5 2 3 1
4 8 5 2 3 1
4 9 5 2 3 1
4 10 5 2 3 1
4 11 5 2 3 1
4 12 5 2 3 1
4 13 5 2 3 1
4 14 5 2 3 1
4 15 5 2 3 1
4 16 5 2 3 1
4 17 5 2 3 1
4 18 5 2 3 1
4 19 5 2 3 1
4 20 5 2 3 1
4 21 5 2 3 1
4 22 5 2 3 1
4 23 5 2 3 1
4 24 5 2 3 1
4 25 5 2 3 1
...
...
...
*/