Multiple Dwellings
Baker, Cooper, Fletcher, Miller and Smith live on different floors of an apartment house that contains only five floors.
Baker does not live on the top floor. Cooper does not live on the bottom floor.
Fletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper.
Smith does not live on a floor adjacent to Fletcher’s.
Fletcher does not live on a floor adjacent to Cooper’s. Where does everyone live?

--Baker, Cooper, Fletcher, Miller and Smith住在一座房子的不同楼层.

--Baker 不住顶层.

--Cooper不住底层.

--Fletcher 既不住顶层也不住底层.
--Miller住得比Cooper高.
--Smith住的楼层和Fletcher不相邻.
--Fletcher住的楼层和Cooper不相邻.

 
select*from
(select (number) Baker from master.dbo.spt_values where type='P' and number between 1 and 5 ) as a,
(select (number) Cooper from master.dbo.spt_values where type='P' and number between 1 and 5 ) as b,
(select (number) Fletcher from master.dbo.spt_values where type='P' and number between 1 and 5 ) as c ,
(select (number) Miller from master.dbo.spt_values where type='P' and number between 1 and 5 ) as d,
(select (number) Smith from master.dbo.spt_values where type='P' and number between 1 and 5 ) as e
where
Baker<>5 and
Cooper<>1 and
Fletcher not in (1,5) and
Miller>Cooper and
abs(Smith-Fletcher)<>1 and
abs(Fletcher-Cooper)<>1
and Baker<>Cooper
and Baker<>Fletcher
and Baker<>Miller
and Baker<>Smith
and Cooper<>Fletcher
and Cooper<>Miller
and Cooper<>Smith
and Fletcher<>Miller
and Fletcher<>Smith
and Smith<>Miller

查询结果

SQL谜题(楼层谜题)的更多相关文章

  1. Java谜题——库谜题

    1.Java中的不可变对象和可变对象 (1)不可变类:当你获得这个类的实例的引用之后,你不可以改变这个实例的内容.比如:String,BigInteger,BigDecimal,还有基本数据类型的封装 ...

  2. Java谜题——类谜题(二)

    1.域的隐藏 代码如下: class Base { public String className = "Base"; } class Derived extends Base { ...

  3. [TJOI2015] 棋盘

    Description 为了提高智商,ZJY去新世界旅游了.可是旅游过后的ZJY杯具的发现要打开通往原来世界的门,必须要解开门上面画的谜题.谜题是这样的:有个\(n\)行\(m\)列的棋盘,棋盘上可以 ...

  4. 比特币运行原理[z]

    https://baijiahao.baidu.com/s?id=1581755535769652543&wfr=spider&for=pc 这篇文章主要讲解比特币是什么?它的运行原理 ...

  5. 【nodejs】理想论坛帖子下载爬虫1.07 使用request模块后稳定多了

    在1.06版本时,访问网页采用的时http.request,但调用次数多以后就问题来了. 寻找别的方案时看到了https://cnodejs.org/topic/53142ef833dbcb076d0 ...

  6. nodejs源码—初始化

    概述 相信很多的人,每天在终端不止一遍的执行着node这条命令,对于很多人来说,它就像一个黑盒,并不知道背后到底发生了什么,本文将会为大家揭开这个神秘的面纱,由于本人水平有限,所以只是讲一个大概其,主 ...

  7. SQL 谜题(硬币的组合)

    问题:早在ITPUB中看过有个SQL高手,喜欢出谜题,以下是一个谜题.我试用SQL SERVER解决此问题. 用1分,5分,10分,25分,50分硬币凑成一元,总共有几种组合办法? SELECT'1* ...

  8. SQL谜题(加减符号替代)

    问题:将以下字符串”.1.2.3.4.5.6.7.8.9 = 1“中的符号点(.)更改为符号加(+)或符号(-),有多少种方法?请用SQL解决此问题 计算过程: CREATE TABLE #(VAL ...

  9. SQL 谜题(父亲的邮票)

    问题:父亲需要些1分,2分,3分,5分,10分的邮票, 其中两种各买四张,另外的三种各买三张 我忘记是哪几种了?他给了我一些10分硬币,金额刚好买这些邮票 计算及分析过程: --通过极限算法,若都是3 ...

随机推荐

  1. Nginx中root与alias的用法及区别:

    Nginx中root与alias都是定义location {}块中虚拟目录访问的文件位置: 先看看两者在用法上的区别: location /img/ { alias /var/www/image/; ...

  2. Js获取当前日期时间及其它操作

    Js获取当前日期时间及其它操作var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份 ...

  3. rpm查询命令摘要

    任务 命令 显示软件包的相关信息 rpm -q -i NAME 列出软件包中含有的所有文件 rpm -q -i NAME 列出软件包中含有的配置文件 rpm -q -c NAME 列出软件包中含有的文 ...

  4. Error:Excepted resource of type id

    This inspection looks at Android API calls that have been annotated with various support annotations ...

  5. 架构和模式的区别:三层架构和MVC在应用开发中的位置

    架构是系统层面的,可以是多层架构,也可以是事件驱动架构,也可以是微服务架构. 模式是GUI应用的一种职责分离设计. 三层架构(包含多层架构)和 MVC模式(包含MVP, MVVM) 没什么关系,它们不 ...

  6. [CodeWars][JS]实现链式加法

    在知乎上看到这样一个问题:http://www.zhihu.com/question/31805304; 简单地说就是实现这样一个add函数: add(x1)(x2)(x3)...(xn) == x1 ...

  7. selenium webdriver 建行软键盘输入密码

    driver.get("https://ibsbjstar.ccb.com.cn/app/V5/CN/STY1/login.jsp"); driver.manage().timeo ...

  8. CI 扩展 Service

    CI 扩展 Service 说明 CodeIgniter是一套典型的MVC框架,M负责数据,C负责交互,V负责视图,但是随着业务逻辑越来越复杂, 必然会涉及到一些列操作过程,例如用户下订单,就会存在校 ...

  9. Python3.5之TuShare

    这部分是直接搬运过来的,官方网站http://tushare.waditu.com/ TuShare是一个免费.开源的python财经数据接口包.主要实现对股票等金融数据从数据采集.清洗加工 到 数据 ...

  10. 应用商店后台MIS的一些思考

    1.有些签名验证的工作应该在开发者上传APP的时候进行校验: 1)如果是更新新版本(包名packagename一致),那么需要验证两个APK的包的签名是否一致,不一致的,应该限制上传,除非先下架旧的A ...