SQL谜题(楼层谜题)
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谜题(楼层谜题)的更多相关文章
- Java谜题——库谜题
1.Java中的不可变对象和可变对象 (1)不可变类:当你获得这个类的实例的引用之后,你不可以改变这个实例的内容.比如:String,BigInteger,BigDecimal,还有基本数据类型的封装 ...
- Java谜题——类谜题(二)
1.域的隐藏 代码如下: class Base { public String className = "Base"; } class Derived extends Base { ...
- [TJOI2015] 棋盘
Description 为了提高智商,ZJY去新世界旅游了.可是旅游过后的ZJY杯具的发现要打开通往原来世界的门,必须要解开门上面画的谜题.谜题是这样的:有个\(n\)行\(m\)列的棋盘,棋盘上可以 ...
- 比特币运行原理[z]
https://baijiahao.baidu.com/s?id=1581755535769652543&wfr=spider&for=pc 这篇文章主要讲解比特币是什么?它的运行原理 ...
- 【nodejs】理想论坛帖子下载爬虫1.07 使用request模块后稳定多了
在1.06版本时,访问网页采用的时http.request,但调用次数多以后就问题来了. 寻找别的方案时看到了https://cnodejs.org/topic/53142ef833dbcb076d0 ...
- nodejs源码—初始化
概述 相信很多的人,每天在终端不止一遍的执行着node这条命令,对于很多人来说,它就像一个黑盒,并不知道背后到底发生了什么,本文将会为大家揭开这个神秘的面纱,由于本人水平有限,所以只是讲一个大概其,主 ...
- SQL 谜题(硬币的组合)
问题:早在ITPUB中看过有个SQL高手,喜欢出谜题,以下是一个谜题.我试用SQL SERVER解决此问题. 用1分,5分,10分,25分,50分硬币凑成一元,总共有几种组合办法? SELECT'1* ...
- SQL谜题(加减符号替代)
问题:将以下字符串”.1.2.3.4.5.6.7.8.9 = 1“中的符号点(.)更改为符号加(+)或符号(-),有多少种方法?请用SQL解决此问题 计算过程: CREATE TABLE #(VAL ...
- SQL 谜题(父亲的邮票)
问题:父亲需要些1分,2分,3分,5分,10分的邮票, 其中两种各买四张,另外的三种各买三张 我忘记是哪几种了?他给了我一些10分硬币,金额刚好买这些邮票 计算及分析过程: --通过极限算法,若都是3 ...
随机推荐
- SFDC中的DEBUG
SFDC的顾问初期,基本都是做一些配置的工作,权限,字段,工作流和审批流之类.那么在这些工作流或者审批流没有按照你预想的来运行而且你检查了多遍后没有找到问题所在的时候.你就需要DEBUG了. 做过开发 ...
- 使用powershell批量修改文本为utf8
根据上一篇powershell生成pro的方法,增加一个批量修改文本文件为utf8格式的方法 $incPath = dir -filter "*.c" -Recurse $temp ...
- node.js
学习网址:http://www.jdon.com/idea/nodejs/
- 5天揭秘js高级技术-第一天
一.基础杂记 1. document.write() <script type="text/javascript"> document.write('<h2> ...
- 高可用mysql之MHA的原理
MHA 如何工作的? MHA是如何工作的? ============================================================================== ...
- OPP Services Log
SELECT FCPP.CONCURRENT_REQUEST_ID REQ_ID, FCP.NODE_NAME, FCP.LOGFILE_NAME FROM FND_CONC_PP_ACTIONS ...
- C#如何获取本机网络IP地址
在开发过程中我们经常会碰到需要IP地址,用来记录用户上次登录的时间地址,或者sokect网络编程等等,下面介绍两种方式: 1. public static string GetIP() { retur ...
- C#操作mysql数据库
转 http://www.jb51.net/article/43486.htm using System;using System.Configuration;using MySql.Data.My ...
- STL~heap
1.定义 堆:若将此序列所存储的向量R[1..n]看做是一棵完全二叉树的存储结构,则堆实质上是满足如下性质的完全二叉树 树中任一非叶子结点的关键字均不大于(或不小于)其子结点的关键字.分为大根数(默认 ...
- Jni 调试 : eclipse + Vs 联合调试
摘要: 本文原创,转载请注明地址 http://www.cnblogs.com/baokang/p/4982640.html 1.在Eclipse 中,Java 类中链接库引用到vs的debug目录下 ...