如果不要求 a,b,c 不同, 就可以像上面那样推理。
喔,忘了个条件,a,b,c 要求不相同
SQL> with t as (select level n from dual connect by level <=9)
2 select a,b,c,max_value
3 from (
4 select a.n a,b.n b,c.n c,
5 max(1/(a.n+2019/(b.n+1/c.n))) over() max_value,
6 rank () over( order by 1/(a.n+2019/(b.n+1/c.n)) desc) rk
7 from t a,t b,t c
8 where a.n <> b.n and b.n <> c.n and c.n <> a.n --增加条件
9 )
10 where rk = 1;
A B C MAX_VALUE
---------- ---------- ---------- ----------
2 9 1 0.00490436
怎么知道a,c=1,2还是2,1分母更小?
with a as (select level l from dual connect by level<=9)
select * from (
select max(1/(a.l+2019/(b.l+1/c.l))) keep(dense_rank first order by 1/(a.l+2019/(b.l+1/c.l)) desc) value,
max(a.l||','||b.l||','||c.l) keep(dense_rank first order by 1/(a.l+2019/(b.l+1/c.l)) desc) key from a a, a b, a c where
a.l<>b.l and b.l<>c.l
and a.l<>c.l) ;
value key
0.004904364884747425208435507601765571358509 2,9,1
口算:1/(a+2019/(b+1/c)),要使得表达式的值最大,那分母要最小 a+2019/(b+1/c),a最小取1, 2019/(b+1/c)最小,那么 (b+1/c)要求最大,b最大9,1/c最大,C取最小,c=1
小菜一碟
with t as (select level n from dual connect by level <=9)
select a,b,c,max_value
from (
select a.n a,b.n b,c.n c,
max(1/(a.n+2019/(b.n+1/c.n))) over() max_value,
rank () over( order by 1/(a.n+2019/(b.n+1/c.n)) desc) rk
from t a,t b,t c
)
where rk = 1
;
1 9 1 0.00492853622474125
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(6)
如果不要求 a,b,c 不同, 就可以像上面那样推理。
喔,忘了个条件,a,b,c 要求不相同
SQL> with t as (select level n from dual connect by level <=9)
2 select a,b,c,max_value
3 from (
4 select a.n a,b.n b,c.n c,
5 max(1/(a.n+2019/(b.n+1/c.n))) over() max_value,
6 rank () over( order by 1/(a.n+2019/(b.n+1/c.n)) desc) rk
7 from t a,t b,t c
8 where a.n <> b.n and b.n <> c.n and c.n <> a.n --增加条件
9 )
10 where rk = 1;
A B C MAX_VALUE
---------- ---------- ---------- ----------
2 9 1 0.00490436
怎么知道a,c=1,2还是2,1分母更小?
with a as (select level l from dual connect by level<=9)
select * from (
select max(1/(a.l+2019/(b.l+1/c.l))) keep(dense_rank first order by 1/(a.l+2019/(b.l+1/c.l)) desc) value,
max(a.l||','||b.l||','||c.l) keep(dense_rank first order by 1/(a.l+2019/(b.l+1/c.l)) desc) key from a a, a b, a c where
a.l<>b.l and b.l<>c.l
and a.l<>c.l) ;
value key
0.004904364884747425208435507601765571358509 2,9,1
口算:1/(a+2019/(b+1/c)),要使得表达式的值最大,那分母要最小 a+2019/(b+1/c),a最小取1, 2019/(b+1/c)最小,那么 (b+1/c)要求最大,b最大9,1/c最大,C取最小,c=1
小菜一碟
with t as (select level n from dual connect by level <=9)
select a,b,c,max_value
from (
select a.n a,b.n b,c.n c,
max(1/(a.n+2019/(b.n+1/c.n))) over() max_value,
rank () over( order by 1/(a.n+2019/(b.n+1/c.n)) desc) rk
from t a,t b,t c
)
where rk = 1
;
A B C MAX_VALUE
1 9 1 0.00492853622474125