楼主: newkid

[每日一题] puzzleup 2021

[复制链接]
论坛徽章:
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
11#
发表于 2021-9-2 13:37 | 只看该作者
本帖最后由 〇〇 于 2021-9-2 13:49 编辑

37:258
http://oeis.org/search?q=8%2C66% ... glish&go=Search

使用道具 举报

回复
论坛徽章:
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
12#
发表于 2021-9-2 20:09 | 只看该作者
我回复的贴子被吞了

使用道具 举报

回复
论坛徽章:
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
13#
发表于 2021-9-2 20:10 | 只看该作者
solomon_007 发表于 2021-9-2 20:09
我回复的贴子被吞了

#1


SQL> with t(n,x,y) as
  2  (select 1,0,0 from dual
  3   union all
  4   select 2,1,0 from dual
  5   union all
  6   select 3,2,0 from dual
  7   union all
  8   select 4,1/2,sqrt(3)/2 from dual
  9   union all
10   select 5,3/2,sqrt(3)/2 from dual
11   union all
12   select 6,1,sqrt(3) from dual
13   union all
14   select 7,0,sqrt(3) from dual
15  ),
16  s (n,x,y) as (
17  select rownum rn,x,y
18  from (
19        select distinct x,y
20        from (
21              select x,y from t
22              union all
23              select -x,y from t
24              union all
25              select -x,-y from t
26              union all
27              select x,-y from t
28             )
29         order by x,y
30       )
31  )
32  select count(*)
33    from (
34          select a.n n1,b.n n2,c.n n3,
35                 round(sqrt(power(a.x-b.x,2)+power(a.y-b.y,2)),2) ab,
36                 round(sqrt(power(a.x-c.x,2)+power(a.y-c.y,2)),2) ac,
37                 round(sqrt(power(b.x-c.x,2)+power(b.y-c.y,2)),2) bc
38            from s a,s b,s c
39           where
40                 a.n < b.n
41             and b.n < c.n
42         )
43   where ab=ac
44     and ac=bc
45  /

  COUNT(*)
----------
        66

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期: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
14#
 楼主| 发表于 2021-9-2 22:02 | 只看该作者
给猫猫发一个章。
我的写法:

    *   *   *
  *   *   *   *
*   *   *   *   *   ------- 首先构造出这一行的坐标,Y=0, X=0,2,4,6,8,然后延申构造出上下各两行的坐标
  *   *   *   *     ------- 纵向点距设为1, 实际上应该为根号3, 在计算距离的时候补回来
    *   *   *


with m as (
SELECT (LEVEL-1)*2 AS X  ---- 构造出中间一行的坐标
      ,0 AS Y
  FROM DUAL
CONNECT BY LEVEL<=5
)
,d as (  --------- 延申构造出上下各两行的坐标
select m.x+abs(n) as x
      ,m.y+n as y
      ,rownum as id
  from m,(select level-3 n from dual connect by level<=5)
where abs(n)+m.x/2<=4
)
select *
from d d1,d d2,d d3
where d1.id<d2.id and d2.id<d3.id
and (d2.y-d1.y)*(d2.y-d1.y)*3+(d2.x-d1.x)*(d2.x-d1.x)   --------- 纵向乘以3补偿
    = (d3.y-d1.y)*(d3.y-d1.y)*3+(d3.x-d1.x)*(d3.x-d1.x)
and (d2.y-d1.y)*(d2.y-d1.y)*3+(d2.x-d1.x)*(d2.x-d1.x)
    = (d3.y-d2.y)*(d3.y-d2.y)*3+(d3.x-d2.x)*(d3.x-d2.x);

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期: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
15#
 楼主| 发表于 2021-9-2 22:06 | 只看该作者
猫的回复被审核,我全放出来了。

使用道具 举报

回复
论坛徽章:
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
16#
发表于 2021-9-2 22:23 | 只看该作者
newkid 发表于 2021-9-2 22:06
猫的回复被审核,我全放出来了。

还有其他贴子的回帖,也被河蟹了。。。WHAT THE FUCK!

你构造坐标的方法更好,我是手动构造第一象限,再复制3份,再去重

使用道具 举报

回复
论坛徽章:
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
17#
发表于 2021-9-2 22:24 | 只看该作者
极坐标版本

with
s as (select generate_series(1,6,1) i),
p as (select 0 d,0 r
union all select 1,pi()/3*i from s
union all select 2,pi()/3*i from s
union all select sqrt(3),pi()/6+pi()/3*i from s),
t as(select p.*,row_number()over() rn from p),
e as(
select row_number()over() n,p1.rn p1,p2.rn p2,(p1.d^2+p2.d^2-2*p1.d*p2.d*cos(p1.r-p2.r))::int d from t p1,t p2
where p1.rn>p2.rn),
tri as(
select e1.d from e e1,e e2
where e1.n>e2.n and e1.d=e2.d and e1.p1=e2.p1 and exists(select 1 from
e e3 where e3.d=e2.d and(e3.p1,e3.p2) in((e1.p2,e2.p2),(e2.p2,e1.p2))))
select count(*)cnt,d from tri group by rollup(d);

使用道具 举报

回复
论坛徽章:
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
18#
发表于 2021-9-2 22:26 | 只看该作者
n=4就很辛苦了

as (select 0 d,0 r
union all select 1,pi()/3*i from s
union all select 2,pi()/3*i from s
union all select sqrt(3),pi()/6+pi()/3*i from s
union all select 3,pi()/3*i from s
union all select 3*sqrt((1/6.0)^2+3/4.0),pi()/6-atan(1.0/6/(sqrt(3)/2))+pi()/3*i from s
union all select 3*sqrt((1/6.0)^2+3/4.0),pi()/6+atan(1.0/6/(sqrt(3)/2))+pi()/3*i from s
union all select 4,pi()/3*i from s
union all select 2*sqrt(3),pi()/6+pi()/3*i from s
union all select 4*sqrt((1/4.0)^2+3/4.0),pi()/6-atan(1.0/4/(sqrt(3)/2))+pi()/3*i from s
union all select 4*sqrt((1/4.0)^2+3/4.0),pi()/6+atan(1.0/4/(sqrt(3)/2))+pi()/3*i from s
),

使用道具 举报

回复
论坛徽章:
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
19#
发表于 2021-9-2 22:30 | 只看该作者
我想了一下,想还是用直角坐标,用到圆心的距离筛选不同的n

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期: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
20#
 楼主| 发表于 2021-9-3 01:02 | 只看该作者
我全用整数坐标,都用不着根号。

使用道具 举报

回复

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

本版积分规则 发表回复

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