楼主: 〇〇

[转载] Project Euler解题汇总(更新至309在1楼)

[复制链接]
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
61#
发表于 2010-11-7 13:12 | 只看该作者
原帖由 newkid 于 10-11-7 10:10 发表

Pandigital_number应该就是1-N的连续自然数的排列吧?N


不知道诶,e文的懒得去仔细看了,反正是没明白
这些题在 http://projecteuler.net/  上都有,我已经注册了个帐户去做了几个题了
发现上面好几个题跟 Pandigital_number 有关。。。

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
62#
发表于 2010-11-7 13:19 | 只看该作者
我也转个简单的题:
26、 Find the value of d < 1000 for which 1/d contains the longest recurring cycle.

A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:

    1/2        =         0.5
    1/3        =         0.(3)
    1/4        =         0.25
    1/5        =         0.2
    1/6        =         0.1(6)
    1/7        =         0.(142857)
    1/8        =         0.125
    1/9        =         0.(1)
    1/10        =         0.1

Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.

Find the value of d < 1000 for which  1/d contains the longest recurring cycle in its decimal fraction part.
————————————————————————————————————————
在d小于1000的数中,找出1/d的循环部分最长的d。
比如

    1/2        =         0.5
    1/3        =         0.(3)
    1/4        =         0.25
    1/5        =         0.2
    1/6        =         0.1(6)
    1/7        =         0.(142857)
    1/8        =         0.125
    1/9        =         0.(1)
    1/10        =         0.1
0.1(6) 表示 0.166666..., 同时也说明其只包含1位数字循环. 也很容易看出1/7有6位数字循环,是2~10里面循环部分最长的.

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
63#
发表于 2010-11-7 16:04 | 只看该作者

回复 #62 lastwinner 的帖子

这个题其实是看似简单,但实际上可能会需要用到大数相除的算法才能发现重复的字符串
用windows计算器试验了一下,1/97=0.010309278350515463917525773195876.....
看了一会儿也没看出来从哪儿开始重复了,不过你不要怀疑他是个无限不循环小数,有理数的倒数都是有理数的,至多也就是无限循环小数

这个题我想到的一个变通的解法是找出1000以内的所有的除了2和5之外的质数和其倒数,以及这些质数的乘积,然后判断到底是哪个质数或者哪几个质数的乘积,他的倒数的循环部分数字会是最长的。

2和5这两个因子无助于增长循环部分的长度,故而不需要考虑他们

不过目前尝试了几个数字,都不是正确答案:
833
841
893
929  --最大的尾数是9的素数
931
977
989
997

但在最后一试的时候,居然对了
Answer is:983

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
64#
发表于 2010-11-7 16:16 | 只看该作者

回复 #63 lastwinner 的帖子

有人给出的结果是(不换行界面就很难看,所以,还是换行吧)
0.(
00101729399796541200406917599186164801627670396
74465920651068158697863682604272634791454730417
09053916581892166836215666327568667344862665310
27466937945066124109867751780264496439471007121
05798575788402848423194303153611393692777212614
44557477110885045778229908443540183112919633774
16073245167853509664292980671414038657171922685
65615462868769074262461851475076297049847405900
30518819938962360122075279755849440488301119023
39776195320447609359104781281790437436419125127
16174974567650050864699898270600203458799593082
40081383519837232960325534079348931841302136317
39572736520854526958290946083418107833163784333
67243133265513733468972533062054933875890132248
21973550356052899287894201424211597151576805696
84638860630722278738555442522889114954221770091
55645981688708036622583926754832146490335707019
32858596134282807731434384537131230925737538148
52492370295015259409969481180061037639877924720
24415055951169888097660223804679552390640895218
718209562563580874872838250254323499491353
)


这个题计算机去做真是不简单,首先,大数计算,其次,查找重复串
http://projecteuler.net/index.ph ... mp;id=26&page=5 里,我看了好几个语言写的算法,不过,没看懂……

[ 本帖最后由 lastwinner 于 2010-11-7 16:18 编辑 ]

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
65#
发表于 2010-11-8 00:13 | 只看该作者
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6^(th) prime is 13.
What is the 10001^(st) prime number?

从2开始,找到第10001个素数(质数)。
————————————————————————————————————


WITH t AS (
    SELECT 2*ROWNUM+1 rn FROM DUAL CONNECT BY ROWNUM <= (160000)/2-1-1
    )
select pn from (
select pn , rank()over(order by pn) rk from (
SELECT rn AS pn from t
MINUS
SELECT t1.rn * t2.rn  FROM t t1, t t2
WHERE t1.rn <= t2.rn AND t1.rn < 400   AND t1.rn * t2.rn <160000
UNION
SELECT 2 FROM DUAL))
where rk=10001
/

得结果为 104743

160000和400是逐步调出的
含义即在160000之内寻找素数,400则是160000的平方根,意即160000之内的数字如果是合数,则其至少有一个约数是不超过400的




这个算法是newkid的


偶采用了一个不合适的思路,速度非常慢:
--创建表做记录
create table prime(pn number);
--初始化
insert into prime select 2 from dual union select 3  from dual union select 5 from dual union select 7  from dual;
--不断执行下面的sql,直到prime表中记录达到或超过10001为止
insert into prime
with t as (select max(pn) curr_max_pn from prime),
candidate as (select c from (select rownum*2+curr_max_pn c from t  connect by rownum<=least(10000, power(curr_max_pn,2))) where substr(c, -1)<>'5' and mod(c,3)>0 and mod(c,7)>0)
--select cand.c from candidate cand, (select * from prime union select 1 from dual)  p where P.PN<=sqrt(cand.c) and mod(cand.c, p.pn)=0 group by  cand.c having count(*)=1 order by 1
select c from candidate minus select cand.c from candidate cand, prime p where P.PN<=sqrt(cand.c) and mod(cand.c, p.pn)=0 group by  cand.c;

我的思路其实适合于分解合数。。。

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
66#
发表于 2010-11-8 00:27 | 只看该作者

回复 #65 lastwinner 的帖子

上面的是 问题7

下面看问题6
The sum of the squares of the first ten natural numbers is,
1^(2) + 2^(2) + ... + 10^(2) = 385

The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^(2) = 55^(2) = 3025

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.


这个很简单
with t as (select rownum rn from dual connect by rownum<=100)
select power(sum(rn),2)-sum(power(rn,2)) from t;

25164150

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
67#
发表于 2010-11-8 00:32 | 只看该作者
问题10
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.
——————————————————————————————————
找出200万之内的所有素数的和


依旧是newkid的写法:
WITH t AS (
    SELECT 2*ROWNUM+1 rn FROM DUAL CONNECT BY ROWNUM <= (2000000)/2-1-1
    )
select sum(pn) from (
SELECT rn AS pn from t
MINUS
SELECT t1.rn * t2.rn  FROM t t1, t t2
WHERE t1.rn <= t2.rn AND t1.rn < 1450   AND t1.rn * t2.rn <2000000
UNION
SELECT 2 FROM DUAL)
/

运行了一两分钟出了结果:
142913828922

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
68#
发表于 2010-11-8 00:41 | 只看该作者
问题12
Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
89261670696623633820136378418383684178734361726757
28112879812849979408065481931592621691275889832738
44274228917432520321923589422876796487670272189318
47451445736001306439091167216856844588711603153276
70386486105843025439939619828917593665686757934951
62176457141856560629502157223196586755079324193331
64906352462741904929101432445813822663347944758178
92575867718337217661963751590579239728245598838407
58203565325359399008402633568948830189458628227828
80181199384826282014278194139940567587151170094390
35398664372827112653829987240784473053190104293586
86515506006295864861532075273371959191420517255829
71693888707715466499115593487603532921714970056938
54370070576826684624621495650076471787294438377604
53282654108756828443191190634694037855217779295145
36123272525000296071075082563815656710885258350721
45876576172410976447339110607218265236877223636045
17423706905851860660448207621209813287860733969412
81142660418086830619328460811191061556940512689692
51934325451728388641918047049293215058642563049483
62467221648435076201727918039944693004732956340691
15732444386908125794514089057706229429197107928209
55037687525678773091862540744969844508330393682126
18336384825330154686196124348767681297534375946515
80386287592878490201521685554828717201219257766954
78182833757993103614740356856449095527097864797581
16726320100436897842553539920931837441497806860984
48403098129077791799088218795327364475675590848030
87086987551392711854517078544161852424320693150332
59959406895756536782107074926966537676326235447210
69793950679652694742597709739166693763042633987085
41052684708299085211399427365734116182760315001271
65378607361501080857009149939512557028198746004375
35829035317434717326932123578154982629742552737307
94953759765105305946966067683156574377167401875275
88902802571733229619176668713819931811048770190271
25267680276078003013678680992525463401061632866526
36270218540497705585629946580636237993140746255962
24074486908231174977792365466257246923322810917141
91430288197103288597806669760892938638285025333403
34413065578016127815921815005561868836468420090470
23053081172816430487623791969842487255036638784583
11487696932154902810424020138335124462181441773470
63783299490636259666498587618221225225512486764533
67720186971698544312419572409913959008952310058822
95548255300263520781532296796249481641953868218774
76085327132285723110424803456124867697064507995236
37774242535411291684276865538926205024910326572967
23701913275725675285653248258265463092207058596522
29798860272258331913126375147341994889534765745501
18495701454879288984856827726077713721403798879715
38298203783031473527721580348144513491373226651381
34829543829199918180278916522431027392251122869539
40957953066405232632538044100059654939159879593635
29746152185502371307642255121183693803580388584903
41698116222072977186158236678424689157993532961922
62467957194401269043877107275048102390895523597457
23189706772547915061505504953922979530901129967519
86188088225875314529584099251203829009407770775672
11306739708304724483816533873502340845647058077308
82959174767140363198008187129011875491310547126581
97623331044818386269515456334926366572897563400500
42846280183517070527831839425882145521227251250327
55121603546981200581762165212827652751691296897789
32238195734329339946437501907836945765883352399886
75506164965184775180738168837861091527357929701337
62177842752192623401942399639168044983993173312731
32924185707147349566916674687634660915035914677504
99518671430235219628894890102423325116913619626622
73267460800591547471830798392868535206946944540724
76841822524674417161514036427982273348055556214818
97142617910342598647204516893989422179826088076852
87783646182799346313767754307809363333018982642090
10848802521674670883215120185883543223812876952786
71329612474782464538636993009049310363619763878039
62184073572399794223406235393808339651327408011116
66627891981488087797941876876144230030984490851411
60661826293682836764744779239180335110989069790714
85786944089552990653640447425576083659976645795096
66024396409905389607120198219976047599490197230297
64913982680032973156037120041377903785566085089252
16730939319872750275468906903707539413042652315011
94809377245048795150954100921645863754710598436791
78639167021187492431995700641917969777599028300699
15368713711936614952811305876380278410754449733078
40789923115535562561142322423255033685442488917353
44889911501440648020369068063960672322193204149535
41503128880339536053299340368006977710650566631954
81234880673210146739058568557934581403627822703280
82616570773948327592232845941706525094512325230608
22918802058777319719839450180888072429661980811197
77158542502016545090413245809786882778948721859617
72107838435069186155435662884062257473692284509516
20849603980134001723930671666823555245252804609722
53503534226472524250874054075591789781264330331690


求出这100个50位数字的和的前10位
————————————————————————————————————————————

如果只考虑前20位数字相加,能否同样的结果?

使用道具 举报

回复
论坛徽章:
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
69#
 楼主| 发表于 2010-11-8 01:03 | 只看该作者
原帖由 lastwinner 于 2010-11-7 13:19 发表
我也转个简单的题:
26、 Find the value of d < 1000 for which 1/d contains the longest recurring cycle.

A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:

    1/2        =         0.5
    1/3        =         0.(3)
    1/4        =         0.25
    1/5        =         0.2
    1/6        =         0.1(6)
    1/7        =         0.(142857)
    1/8        =         0.125
    1/9        =         0.(1)
    1/10        =         0.1

Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.

Find the value of d < 1000 for which  1/d contains the longest recurring cycle in its decimal fraction part.
————————————————————————————————————————
在d小于1000的数中,找出1/d的循环部分最长的d。
比如

    1/2        =         0.5
    1/3        =         0.(3)
    1/4        =         0.25
    1/5        =         0.2
    1/6        =         0.1(6)
    1/7        =         0.(142857)
    1/8        =         0.125
    1/9        =         0.(1)
    1/10        =         0.1
0.1(6) 表示 0.166666..., 同时也说明其只包含1位数字循环. 也很容易看出1/7有6位数字循环,是2~10里面循环部分最长的.

--利用1/i的极限等于999...9/(i*10^n)的原理
set serverout on

declare
max1 number:=1;
pos number:=1;
mod1 number:=1;
mod2 number:=1;
str1 varchar2(4000):='0.';
begin
for i in 980..999 loop
        str1:='0.';--||lpad('0',length(i)-1,'0');
        mod1:=power(10,length(i));
        mod2:=power(10,length(i))-1;
for j in 1..999 loop
        mod1:=mod(mod1*power(10,length(i)),i);
str1:=str1||substr(to_char(trunc(mod2/i)+power(10,length(i))),2);
mod2:=mod(mod2,i);
if mod1=0 then
--dbms_output.put_line('有限小数i=1/'||i);
goto exit1; /*有限小数*/
end if;
if mod2=0 then
pos:=case when (j*length(i))>max1 then i else pos end;
max1:=case when (j*length(i))>max1 then (j*length(i)) else max1 end;
dbms_output.put_line('循环小数i=1/'||i||',长度='||(j*length(i))||',str=('||substr(str1,1,200)||')');
goto exit1; /*循环小数循环节*/
end if;
mod2:=mod2*power(10,length(i))+power(10,length(i))-1;

end loop;
<<exit1>>
NULL;
end loop;
dbms_output.put_line('最长i='||pos||',长度='||max1);
end;
/
循环小数i=1/981,长度=108,str=(0.0010193679918450560652395514780835881753312945973496432212028542303771661569826707441386340468909276
24872579)
循环小数i=1/983,长度=2946,str=(0.001017293997965412004069175991861648016276703967446592065106815869786368260427263479145473041709053
916581892166836215666327568667344862665310274669379450661241098677517802644964394710071210579857578)
循环小数i=1/987,长度=138,str=(0.0010131712259371833839918946301925025329280648429584599797365754812563323201621073961499493414387031
40830800405268490374873353596757852077)
循环小数i=1/989,长度=462,str=(0.0010111223458038422649140546006066734074823053589484327603640040444893832153690596562184024266936299
29221435793731041456016177957532861476238624873609706774519716885743174924165824064711830131445904)
循环小数i=1/991,长度=495,str=(0.0010090817356205852674066599394550958627648839556004036326942482341069626639757820383451059535822401
61453077699293642785065590312815338042381432896064581231079717457114026236125126135216952573158425)
循环小数i=1/993,长度=330,str=(0.0010070493454179254783484390735146022155085599194360523665659617321248741188318227593152064451158106
74723061430010070493454179254783484390735146022155085599194360523665659617321248741188318227593152)
循环小数i=1/997,长度=498,str=(0.0010030090270812437311935807422266800401203610832497492477432296890672016048144433299899699097291875
62688064192577733199598796389167502507522567703109327983951855566700100300902708124373119358074222)
循环小数i=1/999,长度=3,str=(0.001)
最长i=983,长度=2946

[ 本帖最后由 〇〇 于 2010-11-8 01:11 编辑 ]

使用道具 举报

回复
论坛徽章:
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
70#
 楼主| 发表于 2010-11-8 01:24 | 只看该作者
不知道错在哪,输出了重复数字
--利用1/i的极限等于999...9/(i*10^n)的原理
set serverout on

declare
max1 number:=1;
pos number:=1;
mod1 number:=1;
mod2 number:=1;
str1 varchar2(4000):='0.';
str2 varchar2(4000):='0.';
begin
for i in 1..999 loop
        str1:='0.';--||lpad('0',length(i)-1,'0');
        mod1:=power(10,length(i));
        mod2:=power(10,length(i))-1;
for j in 1..999 loop
        mod1:=mod(mod1*power(10,length(i)),i);
str1:=str1||substr(to_char(trunc(mod2/i)+power(10,length(i))),2);
mod2:=mod(mod2,i);
if mod1=0 then
--dbms_output.put_line('有限小数i=1/'||i);
goto exit1; /*有限小数*/
end if;
if mod2=0 then
pos:=case when (j*length(i))>max1 then i else pos end;
str2:=case when (j*length(i))>max1 then str1 else str2 end;
max1:=case when (j*length(i))>max1 then (j*length(i)) else max1 end;
--dbms_output.put_line('循环小数i=1/'||i||',长度='||(j*length(i))||',str=('||substr(str1,1,200)||')');
goto exit1; /*循环小数循环节*/
end if;
mod2:=mod2*power(10,length(i))+power(10,length(i))-1;

end loop;
<<exit1>>
NULL;
end loop;
dbms_output.put_line('最长i='||pos||',长度='||max1||'0.');
for i in 1..40 loop
dbms_output.put_line(substr(str2,3+(i-1)*47,47));
end loop;

end;
/


00101729399796541200406917599186164801627670396
74465920651068158697863682604272634791454730417
09053916581892166836215666327568667344862665310
27466937945066124109867751780264496439471007121
05798575788402848423194303153611393692777212614
44557477110885045778229908443540183112919633774
16073245167853509664292980671414038657171922685
65615462868769074262461851475076297049847405900
30518819938962360122075279755849440488301119023
39776195320447609359104781281790437436419125127
16174974567650050864699898270600203458799593082
40081383519837232960325534079348931841302136317
39572736520854526958290946083418107833163784333
67243133265513733468972533062054933875890132248
21973550356052899287894201424211597151576805696
84638860630722278738555442522889114954221770091
55645981688708036622583926754832146490335707019
32858596134282807731434384537131230925737538148
52492370295015259409969481180061037639877924720
24415055951169888097660223804679552390640895218
71820956256358087487283825025432349949135300101
72939979654120040691759918616480162767039674465
92065106815869786368260427263479145473041709053
91658189216683621566632756866734486266531027466
93794506612410986775178026449643947100712105798
57578840284842319430315361139369277721261444557
47711088504577822990844354018311291963377416073
24516785350966429298067141403865717192268565615
46286876907426246185147507629704984740590030518
81993896236012207527975584944048830111902339776
19532044760935910478128179043743641912512716174
97456765005086469989827060020345879959308240081
38351983723296032553407934893184130213631739572
73652085452695829094608341810783316378433367243
13326551373346897253306205493387589013224821973
55035605289928789420142421159715157680569684638
86063072227873855544252288911495422177009155645
98168870803662258392675483214649033570701932858
59613428280773143438453713123092573753814852492
37029501525940996948118006103763987792472024415

使用道具 举报

回复

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

本版积分规则 发表回复

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