当前位置: 代码迷 >> Sql Server >> 偶也写了个24点~纯无聊(砍破),该如何处理
  详细解决方案

偶也写了个24点~纯无聊(砍破),该如何处理

热度:38   发布时间:2016-04-27 18:23:06.0
偶也写了个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   [email protected]
insert   into   #show   exec( 'select   '[email protected])
if(@@ERROR=8134)
insert   into   #show   select   null
set   @[email protected]+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~我又看看先
------解决方案--------------------
/*             ████████             */
/*          ███人人人人人人人人███          */
/*        ██人人人人人人人人人人人人人人██        */
/*       ██人人人人人人人人人人人人人人人人██       */
/*      █人人人人人人人人人人人人人人人人人人人人█      */
/*     █人人人人人人人人人人人人人人人人人人人人人人█     */
/*    █人人人人人人人人人人人人人人人人人人人人人人人人█    */
/*   ██人人人人人人人人人人人人人人人人人人人人人人人人██   */
/*   █人人人人人人人人██人人人人人人██人人人人人人人人█   */
  相关解决方案