楼主: 〇〇

[精华] puzzleup 2011

[复制链接]
论坛徽章:
519
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
31#
发表于 2011-8-18 05:13 | 只看该作者
原帖由 xqmei 于 2011-8-18 05:02 发表
Am I right? list all the possible, and cal the avg_len?

SQL> SELECT s, length(s) lens, AVG(length(s)) over() avg_len
  2    FROM (SELECT DISTINCT substr(a.s, 1, (least(instr(s, '2'), instr(s, '4')))) s
  3            FROM (SELECT DISTINCT *
  4                    FROM (SELECT n, REPLACE(sys_connect_by_path(n, ','), ',') s
  5                            FROM (SELECT LEVEL n FROM dual CONNECT BY LEVEL  


你列出来的这些情况的权值是不同的,不能这样求平均。这就是为什么我最后要乘上(26-N)!
比如第一位碰到偶数的概率必须是2/4, 你不能把它和第二、三位的情形加起来求平均值。

使用道具 举报

回复
论坛徽章:
519
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
32#
发表于 2011-8-18 05:19 | 只看该作者
原帖由 guostong 于 2011-8-18 04:53 发表
问题1

假设 x 个人
各个entry的最小数目应该是 ceil(x/3)
一共是4个entry
排列是 ceil(x/3)^4

然后判断任意4个没有相同的entry?


(C(X,3)*C(X-3,3)*C(X-6,3)*.....C(3,3))^4

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
33#
 楼主| 发表于 2011-8-24 20:31 | 只看该作者
No: 05       August 24, 2011

A Faulty Pair of Scales

You have a pair of scales which has two production defects:

1) The weight of the two weighing pans are not equal.
2) The lengths of the two arms are not equal.

Using this faulty pair of scales and standard weights you are weighing the balls A, B and C.

· The weights of the balls are even numbers, different from one another.
· When you put balls A and B on the right-side pan, you need to put 20 grams weight on the left-side pan to achieve equilibrium.
· When you put balls B and C on the left-side pan, you need to put 18 grams weight on the right-side pan to achieve equilibrium.
· When you put all three balls on the right-side pan, you need to put X grams weight on the left-side pan to achieve equilibrium whereas when you put all three balls on the left-side pan, you need to put X-5 grams on the right-side pan to achieve equilibrium.

Find the weights of the three balls.

Enter your answer as A,B,C by putting commas between the weights.

使用道具 举报

回复
论坛徽章:
519
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
34#
发表于 2011-8-24 22:04 | 只看该作者
我列了一下,四个方程八个未知数,另外的已知条件是ABC为互不相等的偶数。X也可猜测是正整数。如果能先推理出取值范围,就可以用暴力法。

你有一个天平,它具有两个缺陷:
1. 两个托盘的重量不相等
2. 两边的力臂长度不相等

用这个有缺陷的天平和标准的砝码你试图对A,B,C三个球称重。

每个球的重量是各不相等的偶数。
如果你把A,B放在右托盘,你必须放20克砝码在左托盘以取得平衡。
如果你把B,C放在左托盘,你必须放18克砝码在右托盘以取得平衡。
如果你把所有三个球放在右托盘,你必须放X克砝码在左托盘以取得平衡。
如果你把所有三个球放在左托盘,你必须放X-5克砝码在右托盘以取得平衡。

找出三个球的重量。

假设左托盘重量L, 右托盘重量R, 左力臂长度len_l, 右力臂长度len_r.

(20+L)*len_l = (A+B+R)*len_r
(B+C+L)*len_l = (18+R)*len_r
(X+L)*len_l = (A+B+C+R)*len_r
(A+B+C+L)*len_l = (X-5+R)*len_r

[ 本帖最后由 newkid 于 2011-8-25 01:42 编辑 ]

使用道具 举报

回复
论坛徽章:
519
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
35#
发表于 2011-8-25 21:54 | 只看该作者
把上述方程进行一番消元可以得到:

A*C=(X-20)(X-23)
(B+C-X)(A+B-X+5)=(A+B-18+C)(A+B+C-20)
(B+C-20)(A+B-X+5+C) = (A+B-18)*(A+B+C-X)

自己猜测取值范围,就当是耍个无赖吧。

WITH n AS (SELECT LEVEL*2 n FROM DUAL CONNECT BY LEVEL<=50)
,x AS (SELECT LEVEL X FROM DUAL WHERE LEVEL>20 CONNECT BY LEVEL<=100)
SELECT A.n A,B.n B,C.n C,X
  FROM n A,n B,n C,x
WHERE A.n<>B.n AND A.n<>C.n AND B.n<>C.n
       AND A.n*C.n=(x-20)*(x-23)
       AND (B.n+C.n-X)*(A.n+B.n-X+5)=(A.n+B.n-18+C.n)*(A.n+B.n+C.n-20)
       AND (B.n+C.n-20)*(A.n+B.n-X+5+C.n) = (A.n+B.n-18)*(A.n+B.n+C.n-X);

         A          B          C          X
---------- ---------- ---------- ----------
        18          4         10         35

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
36#
 楼主| 发表于 2011-9-7 10:06 | 只看该作者
No: 06       August 31, 2011

Chess Players

25 players are attending a chess tournament. In every possible combination of five players, at least one of the players has played with the other four players before.

What is the minimum possible number of players in the tournament that has played with all the other 24 players before?
[ You need to be a member of this site

使用道具 举报

回复
论坛徽章:
548
生肖徽章2007版:猴
日期:2008-05-16 11:28:59生肖徽章2007版:马
日期:2008-10-08 17:01:01SQL大赛参与纪念
日期:2011-04-13 12:08:17授权会员
日期:2011-06-17 16:14:53ITPUB元老
日期:2011-06-21 11:47:01ITPUB官方微博粉丝徽章
日期:2011-07-01 09:45:27ITPUB十周年纪念徽章
日期:2011-09-27 16:30:472012新春纪念徽章
日期:2012-01-04 11:51:222012新春纪念徽章
日期:2020-11-30 22:13:24海蓝宝石
日期:2012-02-20 19:24:27
37#
发表于 2011-9-7 11:51 | 只看该作者
原帖由 newkid 于 2011-8-17 22:55 发表
可以理解为:把26个字母全排列,第三个元音出现位置的平均值。

假设第三个元音出现位置为N(取值范围3-24),其排列方法总共有:

C(5,3)*(N-1)!*3*C(26-5,N-1-2)*(26-N)!

求N的平均值。


newkid , 这个总数因该是:

P(5,3)*P(21,N-3) *(26-N)!= C(5,3)*3!*C(21,N-3)*(N-3)!*(26-N)!

[ 本帖最后由 solomon_007 于 2011-9-7 15:10 编辑 ]

使用道具 举报

回复
论坛徽章:
548
生肖徽章2007版:猴
日期:2008-05-16 11:28:59生肖徽章2007版:马
日期:2008-10-08 17:01:01SQL大赛参与纪念
日期:2011-04-13 12:08:17授权会员
日期:2011-06-17 16:14:53ITPUB元老
日期:2011-06-21 11:47:01ITPUB官方微博粉丝徽章
日期:2011-07-01 09:45:27ITPUB十周年纪念徽章
日期:2011-09-27 16:30:472012新春纪念徽章
日期:2012-01-04 11:51:222012新春纪念徽章
日期:2020-11-30 22:13:24海蓝宝石
日期:2012-02-20 19:24:27
38#
发表于 2011-9-7 13:14 | 只看该作者
结果      

        24                                                                    24
P  =  ∑ (N*C(5,3)*3!*C(21,N-3)*(N-3)!*(26-N)! ) /  ∑ C(5,3)*3!*C(21,N-3)*(N-3)!*(26-N)!
      n=3                                                                   n=3

[ 本帖最后由 solomon_007 于 2011-9-7 15:11 编辑 ]

使用道具 举报

回复
论坛徽章:
548
生肖徽章2007版:猴
日期:2008-05-16 11:28:59生肖徽章2007版:马
日期:2008-10-08 17:01:01SQL大赛参与纪念
日期:2011-04-13 12:08:17授权会员
日期:2011-06-17 16:14:53ITPUB元老
日期:2011-06-21 11:47:01ITPUB官方微博粉丝徽章
日期:2011-07-01 09:45:27ITPUB十周年纪念徽章
日期:2011-09-27 16:30:472012新春纪念徽章
日期:2012-01-04 11:51:222012新春纪念徽章
日期:2020-11-30 22:13:24海蓝宝石
日期:2012-02-20 19:24:27
39#
发表于 2011-9-7 15:09 | 只看该作者
newkid 1234的例子:

SQL> create or replace function f_n (p_int in pls_integer)
  2  return pls_integer
  3  is
  4    l_res pls_integer :=0;
  5  begin
  6    if p_int = 1 or p_int = 0 then
  7      l_res := 1;
  8    else
  9      l_res := p_int * f_n(p_int - 1);
10    end if;
11    return l_res;
12  end;
13  /

Function created

SQL>
SQL> create or replace function f_c (p_n in pls_integer,p_m in pls_integer)
  2  return pls_integer
  3  is
  4    l_res pls_integer :=0;
  5  begin
  6    return f_n(p_n)/(f_n(p_m)*f_n(p_n - p_m));
  7  end;
  8  /

Function created

SQL>
SQL> with t  as (select level n from dual connect by level <= 3),
  2       tt as (select n,f_c(2,1)*f_n(1)*f_c(2,n-1)*f_n(n-1)*f_n(4-n) cnt from t)
  3  select sum(n*cnt)/sum(cnt) from tt
  4  /

SUM(N*CNT)/SUM(CNT)
-------------------
   1.66666666666667

使用道具 举报

回复
论坛徽章:
519
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
40#
发表于 2011-9-7 22:19 | 只看该作者
原帖由 solomon_007 于 2011-9-7 11:51 发表


newkid , 这个总数因该是:

P(5,3)*P(21,N-3) *(26-N)!= C(5,3)*3!*C(21,N-3)*(N-3)!*(26-N)!


看看你前面的P(5,3)*P(21,N-3), 意思是3个元音的全排列和N-3个辅音的全排列,但是你忘记了这些元音是可以穿插在辅音当中的,也就是给定你的一个排列还必须乘上元音的分布。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表