找回密码
 欢迎注册
查看: 5826|回复: 1

[游戏] Puzzleup 13 Square of the Sums

[复制链接]
发表于 2009-10-17 08:48:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
No: 13       October 14, 2009  




The square of the sum of four positive integers is equal to the number formed by writing these four numbers side by side. Each of the digits in this number is different. What is the maximum possible value of this number?
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2009-10-17 10:17:16 | 显示全部楼层
居然只有1个解,也就是最大解
create table cc as
with t1 as
(select level l from dual connect by level<=10),
tmp as
(select level*level s from dual connect by level<1E5)
,
tmp2 as
(select s,substr(s,l,1),count(*)cnt from tmp,t1
where l<=length(s)
group by s,substr(s,l,1)
),
tmp3 as
(select s  from tmp2 having max(cnt)=1
group by s)
select * from tmp3;

col s for 9999999999
col s1 for a10
col s2 for a10
col s3 for a10
col s4 for a10

with t1 as
(select level l from dual connect by level<=10),
tn as
(select t1.l t1l,t2.l t2l,t3.l t3l from t1,t1 t2,t1 t3
where t1.l>1 and t1.l<t2.l and t2.l<t3.l and t3.l<=9)
select s,substr(s,1,t1l-1)s1,substr(s,t1l,t2l-t1l)s2,substr(s,t2l,t3l-t2l)s3,substr(s,t3l)s4
from cc,tn where tn.t3l<=length(s)
and substr(s,1,t1l-1)+substr(s,t1l,t2l-t1l)+substr(s,t2l,t3l-t2l)+substr(s,t3l)=sqrt(s);
;

已用时间:  00: 00: 00.00
SQL> col s for 9999999999
SQL> col s1 for a10
SQL> col s2 for a10
SQL> col s3 for a10
SQL> col s4 for a10
SQL>
SQL> with t1 as
  2  (select level l from dual connect by level<=10),
  3  tn as
  4  (select t1.l t1l,t2.l t2l,t3.l t3l from t1,t1 t2,t1 t3
  5  where t1.l>1 and t1.l<t2.l and t2.l<t3.l and t3.l<=9)
  6  select s,substr(s,1,t1l-1)s1,substr(s,t1l,t2l-t1l)s2,substr(s,t2l,t3l-t2l)s
3,substr(s,t3l)s4
  7  from cc,tn where tn.t3l<=length(s)
  8  and substr(s,1,t1l-1)+substr(s,t1l,t2l-t1l)+substr(s,t2l,t3l-t2l)+substr(s,
t3l)=sqrt(s);

          S S1         S2         S3         S4
----------- ---------- ---------- ---------- ----------
     893025 8          930        2          5

已用时间:  00: 00: 00.09

SQL> select 945*945 from dual;

   945*945
----------
    893025
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-4-26 16:07 , Processed in 0.047362 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表