〇〇 发表于 2009-10-17 08:48:41

Puzzleup 13 Square of the Sums

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 sfrom 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),
3tn as
4(select t1.l t1l,t2.l t2l,t3.l t3l from t1,t1 t2,t1 t3
5where t1.l>1 and t1.l<t2.l and t2.l<t3.l and t3.l<=9)
6select s,substr(s,1,t1l-1)s1,substr(s,t1l,t2l-t1l)s2,substr(s,t2l,t3l-t2l)s
3,substr(s,t3l)s4
7from cc,tn where tn.t3l<=length(s)
8and 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
页: [1]
查看完整版本: Puzzleup 13 Square of the Sums