|
〇〇 发表于 2012-1-14 13:56 ![]()
Problem 223
26 December 2008
最后2题,边长到3千已经很慢了
with t as
(select level l,level*level s from dual connect by level<=2e3)
select count(*) from(
select/*+rule*/ a.l al,b.l bl,c.l cl from t a,t b,t c
where
a.s+b.s=c.s-1
and
a.l<=b.l
and
b.l<=c.l)
;
SQL> with t as
2 (select level l,level*level s from dual connect by level<=2e3)
3 select count(*) from(
4 select/*+rule*/ a.l al,b.l bl,c.l cl from t a,t b,t c
5 where
6 a.s+b.s=c.s-1
7 and
8 a.l<=b.l
9 and
10 b.l<=c.l)
11 ;
COUNT(*)
----------
257
已用时间: 00: 00: 02.91
SQL> 6
6* a.s+b.s=c.s-1
SQL> c/-/+
6* a.s+b.s=c.s+1
SQL> /
COUNT(*)
----------
5495
已用时间: 00: 00: 02.92 |
|