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 ...
随机推荐
- eclipse使用sublime配色(转)
转自 Eclipse设置类似Sublime Text 编辑区皮肤,风格,颜色 1.首先打开eclipse 2.help -> Install New SoftWare 3.点击 Add 在Na ...
- split分割大文件--包含通过awk按规则分割文件到对应子文件
当对一个大文件进行传输或者分析的时候,一个可以参考的办法是先通过split对文件进行分割,再对每个子文件进行处理,如果需要合并再进行合并. split函数可以按文件大小或者行数来进行分割. -a : ...
- jsp中超链接路径的写法
主题 超链接不就是一个地址字符串吗?这能有什么花头? LZSB! 曾经我也是这么想的.... 最近对apache的学习让我对网页中超链接,CSS,js的路径的写法有了一些新的认识. 所以这篇文章主要分 ...
- java的锁机制
一段synchronized的代码被一个线程执行之前,他要先拿到执行这段代码的权限,在Java里边就是拿到某个同步对象的锁(一个对象只有一把锁): 如果这个时候同步对象的锁被其他线程拿走了,他(这个线 ...
- Myeclipse 构建工作空间出错
MyEclipse工作空间报错如下:'Building workspace' has encountered a problem. Errors occurred during the build.并 ...
- OS 如何选择delegate、notification、KVO?
原文链接:http://blog.csdn.net/dqjyong/article/details/7685933 前面分别讲了delegate.notification和KVO的实现原理,以及实际使 ...
- secureCRT The remote system refused the connection.
转 http://blog.csdn.net/lifengxun20121019/article/details/13627757 我在实践远程登录工具SecureCRT的时候遇到了这个问题 Ubun ...
- c#过滤html标签
public string HtmlFilter(string html) { //设置要删除的标记 string[] lable = { "font ...
- android onCreate中获取view宽高为0的解决方法
view.post(runnable) 通过post可以将一个runnable投递到消息队列的尾部,然后等待UI线程Looper调用此runnable的时候,view也已经初始化好了. view.po ...
- Eclipse使用技巧
1,整体缩进 右缩进:选中+Tab 左缩进:选中+ Shift+Tab 2,Ctrl+O列出当前类所有方法和属性