日期:2014-05-18  浏览次数:21197 次

偶也写了个24点~纯无聊(砍破)
create   table   #(id   varchar(5))
insert   into   #   select   1
union   all   select   6
union   all   select   6
union   all   select   8

drop   table   #count
create   table   #count(ctid   varchar(5))
insert   into   #count   select   '+ '
union   all   select   '- '
union   all   select   '* '
union   all   select   '/ '

select   identity(int,1,1)   id, '( '+aid+b.ctid+ '( '+bid+c.ctid+ '( '+cid+d.ctid+did+ '))) '[mula]   into   #wei
from
(select   DISTINCT   a.id   [aid],b.id   [bid],c.id   [cid],d.id+ '.0 '   [did]   from   #   a,#   b,#   c,#   d
where   len(REPLACE(a.id+b.id+c.id+d.id, '1 ', ' '))=3  
and   len(REPLACE(a.id+b.id+c.id+d.id, '8 ', ' '))=3  
and   len(REPLACE(a.id+b.id+c.id+d.id, '6 ', ' '))=2)a
,#count   b,#count   c,#count   d

create   table   #show(id   int   identity(1,1),result   dec(18,3))

declare   @int   int,@var   varchar(50)
set   @int=1
while   @int <=(select   max(id)from   #wei)
begin
select   @var=mula   from   #wei   where   id=@int
insert   into   #show   exec( 'select   '+@var)
if(@@ERROR=8134)
insert   into   #show   select   null
set   @int=@int+1
end

select   *   from   #wei   a   join   #show   b   on   b.id=a.id
where   b.result=24

drop   table   #count
drop   table   #
drop   table   #wei
drop   table   #show

id                     mula                                                                                 id                     result                              
-----------   -------------------------------------------   -----------   --------------------  
248                   (6/(1-(6/8.0)))                                                           248                   24.000

------解决方案--------------------
UPUP~我又看看先
------解决方案--------------------
/*             ████████             */
/*          ███人人人人人人人人███          */
/*        ██人人人人人人人人人人人人人人██        */
/*       ██人人人人人人人人人人人人人人人人██       */
/*      █人人人人人人人人人人人人人人人人人人人人█      */
/*     █人人人人人人人人人人人人人人人人人人人人人人█     */
/*    █人人人人人人人人人人人人人人人人人人人人人人人人█    */
/*   ██人人人人人人人人人人人人人人人人人人人人人人人人██   */