我gf說她水平有限,戰時算到1000位,她說csdn可能沒有能強過她的了
3.1415926535 8979323846 2643383279 5028841971 6939937510
5820974944 5923078164 0628620899 8628034825 3421170679
8214808651 3282306647 0938446095 5058223172 5359408128
4811174502 8410270193 8521105559 6446229489 5493038196
4428810975 6659334461 2847564823 3786783165 2712019091
4564856692 3460348610 4543266482 1339360726 0249141273
7245870066 0631558817 4881520920 9628292540 9171536436
7892590360 0113305305 4882046652 1384146951 9415116094
3305727036 5759591953 0921861173 8193261179 3105118548
0744623799 6274956735 1885752724 8912279381 8301194912
9833673362 4406566430 8602139494 6395224737 1907021798
6094370277 0539217176 2931767523 8467481846 7669405132
0005681271 4526356082 7785771342 7577896091 7363717872
1468440901 2249534301 4654958537 1050792279 6892589235
4201995611 2129021960 8640344181 5981362977 4771309960
5187072113 4999999837 2978049951 0597317328 1609631859
5024459455 3469083026 4252230825 3344685035 2619311881
7101000313 7838752886 5875332083 8142061717 7669147303
5982534904 2875546873 1159562863 8823537875 9375195778
1857780532 1712268066 1300192787 6611195909 2164201989
3.1415926535 8979323846 2643383279 5028841971 6939937510
5820974944 5923078164 0628620899 8628034825 3421170679
8214808651 3282306647 0938446095 5058223172 5359408128
4811174502 8410270193 8521105559 6446229489 5493038196
4428810975 6659334461 2847564823 3786783165 2712019091
4564856692 3460348610 4543266482 1339360726 0249141273
7245870066 0631558817 4881520920 9628292540 9171536436
7892590360 0113305305 4882046652 1384146951 9415116094
3305727036 5759591953 0921861173 8193261179 3105118548
0744623799 6274956735 1885752724 8912279381 8301194912
9833673362 4406566430 8602139494 6395224737 1907021798
6094370277 0539217176 2931767523 8467481846 7669405132
0005681271 4526356082 7785771342 7577896091 7363717872
1468440901 2249534301 4654958537 1050792279 6892589235
4201995611 2129021960 8640344181 5981362977 4771309960
5187072113 4999999837 2978049951 0597317328 1609631859
5024459455 3469083026 4252230825 3344685035 2619311881
7101000313 7838752886 5875332083 8142061717 7669147303
5982534904 2875546873 1159562863 8823537875 9375195778
1857780532 1712268066 1300192787 6611195909 2164201989
我猜测的对不对?
我幫妳問了,她說本來想心算,但算了一半就放棄了...太多數據了
你累不累
hnlzh(吸海垂虹)
你总让你GF洗衣服,虐待啊,你去洗
a=10000:c=2800:While b-c<>0:f(b)=a/5:b=b+1:Wend
d=0:g=c*2:While g>0
b=c:d=d+f(b)*a:g=g-1:f(b)=d Mod g:d=d\g:g=g-1:b=b-1
While b>0:d=d*b:d=d+f(b)*a:g=g-1:f(b)=d Mod g:d=d\g:g=g-1:b=b-1:Wend
c=c-14:Print Format(e+d\a,"0###"):e=d Mod a:d=0:g=c*2:Wend拿去算吧。
还好,怎么你心疼了吗? 呵呵
我想妳肯定不是心痛我的gf,hehe..
这么毒辣,想让我没气,不行啊,万一你以后想我怎么办呢???不开玩笑谁有本事,来那分好了mm全部分 dd代理 给一半分
记住 10000 位啊
我不会,我笨死了,我不要分的,我在这凑热闹
别在乱,回家帮GF洗衣服
再见。晚上要睡好啊。
hnlzh(吸海垂虹) :为什么总用繁体?
Dim x, y, n As Double
x = 1 / 5: y = 1 / 239
Screen.MousePointer = 11
For n = 2 To 100000
x = x + (-1) ^ (n - 1) * x ^ (2 * n - 1) / (2 * n - 1)
y = y + (-1) ^ (n - 1) * y ^ (2 * n - 1) / (2 * n - 1)
Next
Screen.MousePointer = 0
Debug.Print "π=" 16 * x - 4 * y
End Sub
对这个积分4/(1+x^2)从0到1
一般都是用复合梯形公式计的。
dim a,b,t1,t2
a=0:b=1:c=0.00001
t1=(b-a)*(4/(1+a^2)+4/(1+b^2))/2)
temp=0
t2=0
for k =1 to 100000
for i=1 to 2^(k-1)
temp=temp+4/(1+(a+(2*i-1)*(b-a)/2^k)^2)
t2=0.5*t1+(b-a)*temp/2^k
debug.print t2
if abs(t2-t1)<c then exit for
next
next
a=0:b=1:c=0.00001
t1=(b-a)*(4/(1+a^2)+4/(1+b^2))/2)
temp=0
t2=0
for k =1 to 100000
for i=1 to 2^(k-1)
temp=temp+4/(1+(a+(2*i-1)*(b-a)/2^k)^2)
t2=0.5*t1+(b-a)*temp/2^k
debug.print t2
if abs(t2-t1)<c then exit for
next
temp=0
t1=t2
next
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <time.h>
#include <conio.h>
#include <io.h>int *arctg5, *arctg239, *tmp;
int DecLen, BinLen;
int x, n, sign, NonZeroPtr;
int Step;
char fn_status[] = "~pi_sts.___";
char fn_arctg5[] = "~atg5.___";
char fn_arctg239[] = "~atg239.___";
char fn_tmp[] = "~tmp.___";
time_t TotalTime, time1, time2;void __cdecl FirstDiv(int *arctg_array)
{
__asm {
mov esi, arctg_array
mov dword ptr [esi], 1
xor edx, edx
mov ebx, x
mov ecx, BinLen
fd1: mov eax, [esi]
div ebx
mov [esi], eax
add esi, 4
loop fd1
mov esi, arctg_array
mov edi, tmp
mov ecx, BinLen
pushf
cld
rep movsd
popf
}
}void __cdecl arctgx(int *arctg_array)
{
int NonZeroBytePtr;
int key;
FILE *fp;
for (;NonZeroPtr<BinLen;) {
NonZeroBytePtr = NonZeroPtr * 4;
if (_kbhit()) {
key=_getch();
if (key==0 || key==0xe0) _getch();
if (key=='p') {
printf("Swap data to disk ...\n");
if (x==25)
Step = 1;
else
Step = 2;
time(&time2);
TotalTime += time2 - time1;
if ((fp=fopen(fn_status,"wt"))==NULL) {
printf("Create file %s error!!\n", fn_status);
exit(0);
}
fprintf(fp, "%d %d %d %d %d %d %d\n",
Step, DecLen, BinLen, n, sign, NonZeroPtr, TotalTime);
fclose(fp);
if ((fp=fopen(fn_arctg5,"wb"))==NULL) {
printf("Create file %s error!!\n", fn_arctg5);
exit(0);
}
if (fwrite(arctg5, 4, BinLen, fp) != (unsigned)BinLen) {
printf("Write file %s error!!\n", fn_arctg5);
exit(0);
}
fclose(fp);
if ((fp=fopen(fn_arctg239,"wb"))==NULL) {
printf("Create file %s error!!\n", fn_arctg239);
exit(0);
}
if (fwrite(arctg239, 4, BinLen, fp) != (unsigned)BinLen) {
printf("Write file %s error!!\n", fn_arctg239);
exit(0);
}
fclose(fp);
if ((fp=fopen(fn_tmp,"wb"))==NULL) {
printf("Create file %s error!!\n", fn_tmp);
exit(0);
}
if (fwrite(tmp, 4, BinLen, fp) != (unsigned)BinLen) {
printf("Write file %s error!!\n", fn_tmp);
exit(0);
}
fclose(fp);
printf("Exit.\n");
exit(0);
}
}
__asm {
mov esi, tmp
add esi, NonZeroBytePtr
xor edx, edx
mov ebx, x
mov ecx, BinLen
sub ecx, NonZeroPtr
arctg1: mov eax, [esi]
div ebx
mov [esi], eax
add esi, 4
loop arctg1
cmp sign, 1
jne sub_
mov esi, tmp
add esi, NonZeroBytePtr
mov edi, arctg_array
add edi, NonZeroBytePtr
xor edx, edx
mov ebx, n
mov ecx, BinLen
sub ecx, NonZeroPtr
add_1: mov eax, [esi]
div ebx
add [edi], eax
adc dword ptr [edi-4], 0
jnc add_3
push edi
sub edi, 4
add_2: sub edi, 4
add dword ptr [edi], 1
jc add_2
pop edi
add_3: add esi, 4
add edi, 4
loop add_1
jmp adj_var
sub_: mov esi, tmp
add esi, NonZeroBytePtr
mov edi, arctg_array
add edi, NonZeroBytePtr
xor edx, edx
mov ebx, n
mov ecx, BinLen
sub ecx, NonZeroPtr
sub_1: mov eax, [esi]
div ebx
sub [edi], eax
sbb dword ptr [edi-4], 0
jnc sub_3
push edi
sub edi, 4
sub_2: sub edi, 4
sub dword ptr [edi], 1
jc sub_2
pop edi
sub_3: add esi, 4
add edi, 4
loop sub_1
adj_var: add n, 2
neg sign
mov esi, tmp
add esi, NonZeroBytePtr
cmp dword ptr [esi], 0
jne adj_var_ok
inc NonZeroPtr
adj_var_ok:
}
}
}void __cdecl mul_array(int *array, int multiplicator)
{
__asm {
mov esi, BinLen
dec esi
shl esi, 2
add esi, array
mov ecx, BinLen
mov ebx, multiplicator
xor edi, edi
mul1: mov eax, [esi]
mul ebx
add eax, edi
adc edx, 0
mov [esi], eax
mov edi, edx
sub esi, 4
loop mul1
mov [esi], edx
}
}void __cdecl sub2array(int *array1, int *array2)
{
__asm {
mov esi, array1
mov edi, array2
mov ecx, BinLen
dec ecx
sub1: mov eax, [edi+ecx*4]
sbb [esi+ecx*4], eax
loop sub1
}
}void main(void)
{
struct tm *ts;
FILE *pi, *fp;
int i, tail, p10tail;
printf("\nProgram to compute PI, by Jason Chen, May 1999.\n");
printf(" Dec Length Time(h:m:s)\n");
printf(" 20000 00:00:07\n");
printf(" 100000 00:02:54\n");
printf(" (Running on PII-233, 128MB, Win98 Dos mode)\n");
printf(" Homepage: jason2000.yeah.net\n");
printf(" Email: [email protected]\n\n");
if ((fp=fopen(fn_status,"rt"))==NULL) {
printf("Decimal length = ");
scanf("%d", &DecLen);
if (DecLen < 100) DecLen = 100;
BinLen = (int)(DecLen / log10(2) / 32) + 2;
Step = 0;
TotalTime = 0;
}
else {
printf("Reading previous data ...\n");
fscanf(fp, "%d %d %d %d %d %d %d",
&Step, &DecLen, &BinLen, &n, &sign, &NonZeroPtr, &TotalTime);
fclose(fp);
if (Step*DecLen*BinLen*n*sign*NonZeroPtr*TotalTime == 0) {
printf("File %s error !!\nExit!\n", fn_status);
exit(0);
}
}
arctg5 = calloc(BinLen, 4);
arctg239 = calloc(BinLen, 4);
tmp = calloc(BinLen, 4);
if (arctg5==NULL || arctg239==NULL || tmp==NULL) {
printf("Not enough memory !!\n");
exit(0);
}
if (Step == 0) {
memset(arctg5, 0, BinLen*4);
memset(arctg239, 0, BinLen*4);
memset(tmp, 0, BinLen*4);
}
else {
if ((fp=fopen(fn_arctg5,"rb"))==NULL) {
printf("Open file %s error!!\n", fn_arctg5);
exit(0);
}
if (fread(arctg5, 4, BinLen, fp) != (unsigned)BinLen) {
printf("File %s error!!\n", fn_arctg5);
exit(0);
}
fclose(fp);
if ((fp=fopen(fn_arctg239,"rb"))==NULL) {
printf("Open file %s error!!\n", fn_arctg239);
exit(0);
}
if (fread(arctg239, 4, BinLen, fp) != (unsigned)BinLen) {
printf("File %s error!!\n", fn_arctg239);
exit(0);
}
fclose(fp);
if ((fp=fopen(fn_tmp,"rb"))==NULL) {
printf("Open file %s error!!\n", fn_tmp);
exit(0);
}
if (fread(tmp, 4, BinLen, fp) != (unsigned)BinLen) {
printf("File %s error!!\n", fn_tmp);
exit(0);
}
fclose(fp);
}
printf("Working ......\n");
printf("Press 'p' to pause & exit\n");
time(&time1);
if (Step == 0) {
x = 5;
FirstDiv(arctg5);
x = x * x;
n = 3;
sign = -1;
NonZeroPtr = 1;
arctgx(arctg5);
}
else if (Step == 1) {
x = 5 * 5;
arctgx(arctg5);
}
if (Step == 0 || Step == 1) {
x = 239;
FirstDiv(arctg239);
x = x * x;
n = 3;
sign = -1;
NonZeroPtr = 1;
arctgx(arctg239);
}
else {
x = 239 * 239;
arctgx(arctg239);
}
mul_array(arctg5, 16);
mul_array(arctg239, 4);
sub2array(arctg5, arctg239);
if ((pi=fopen("pi.txt","wt"))==NULL) {
printf("Create file pi.txt error!!\n");
exit(0);
}
printf("Writing result to file: pi.txt ...\n");
fprintf(pi, "%d", arctg5[0]);
for (i=1; i<=DecLen/9; i++) {
arctg5[0] = 0;
mul_array(arctg5, 1000000000);
fprintf(pi, "%09d", arctg5[0]);
}
tail = DecLen % 9;
p10tail = 1;
for (i=1;i<=tail;i++) p10tail *= 10;
arctg5[0] = 0;
mul_array(arctg5, p10tail);
fprintf(pi, "%0*d", tail, arctg5[0]);
fclose(pi);
time(&time2);
TotalTime += time2 - time1;
printf("Done !!\n");
ts = gmtime(&TotalTime);
ts->tm_mon --;
ts->tm_mday = ts->tm_mday - 1 + ts->tm_mon * 31;
printf("Time : ");
if (ts->tm_mday > 0) printf("%d Day(s) ", ts->tm_mday);
printf("%02d:%02d:%02d\n", ts->tm_hour, ts->tm_min, ts->tm_sec);
if (_unlink(fn_status) == 0) {
_unlink(fn_arctg5);
_unlink(fn_arctg239);
_unlink(fn_tmp);
}
}
pi=16*arctg(1/5) - 4*arctg(1/239)
所以的你的洗衣服的gf 的算法不算正确
不信你试一试,看看能算出多少位
这样吧简单点的 谁能算出 2 的平方根 10000位 就会得到 一半的分
碳离子
不知你准备了多少车硬盘来放啊
wbdx(碳离子) 说:行啊,写吧!
lionprince(狮子王子),wbdx(碳离子)说了 :行啊,写吧! lionprince(狮子王子)
帖出了代碼...............dzbswl(白雪儿):
结果是:3.14154367025329675766243241881295855454217088483382315328918161829235892362167668831156960612640202170735835221294047782591091570411651472186029519906261646730733907419814952960000000000000000000000000000...........
其实很简单,只用10多行代码就实现了 wbdx(碳离子):
dzbswl(白雪儿)不必了,小女孩 弄点分不容易,算了吧!!!
等会给大家加分,谢谢各位
lionprince(狮子王子)
真是无聊,我将答案和原程序都给你们了,你们还要。
dzbswl(白雪儿) (2001-8-10 14:55:07) 得0分
wbdx(碳离子)不行,非给不可,说话要算话,我可不象你dzbswl(白雪儿)
lionprince(狮子王子)你的原程序我一眼都没看,费话太多