主题:[原创]2^n大拼比
tujunqiang
[专家分:150] 发布于 2007-11-09 23:31:00
计算2^n(n>=30)
回复列表 (共4个回复)
沙发
tujunqiang [专家分:150] 发布于 2007-11-10 00:16:00
CLS
INPUT "n="; n
l = INT(n * .30103) + 1
DIM a(l): a(1) = 1
FOR t = 1 TO n
h = INT(t * .30103) + 1
GOSUB 200
NEXT t
PRINT TAB(8); "2^"; n; "=";
FOR k = h TO 1 STEP -1
PRINT USING "#"; a(k);
NEXT k
END
200
c = 0
FOR s = 1 TO h
x = 2 * a(s) + c
c = x \ 10: x = x MOD 10
a(s) = x
NEXT s
RETURN
板凳
小小DAVID [专家分:300] 发布于 2010-01-31 20:40:00
CLS
INPUT N
KK = TIMER
A$ = "1"
FOR I = 1 TO N
L = LEN(A$)
LC = L + 1
REDIM A(L), B(LC)
FOR J = 1 TO L
A(J) = VAL(MID$(A$, LC - J, 1))
NEXT J
FOR J = 1 TO L
X = A(J) * 2
B(J) = B(J) + X MOD 10
B(J + 1) = B(J + 1) + X \ 10 + B(J) \ 10
B(J) = B(J) MOD 10
NEXT J
IF B(LC) = 0 THEN LC = LC - 1
A$ = ""
FOR J = LC TO 1 STEP -1
A$ = A$ + MID$(STR$(B(J)), 2)
NEXT J
NEXT I
PRINT A$
3 楼
小小DAVID [专家分:300] 发布于 2010-01-31 20:42:00
给我50分
4 楼
1054122 [专家分:750] 发布于 2010-02-06 11:56:00
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
long long x , i , n;
cin >> n;
x = 1;
for (i = 1 ; i <= n ; i++) x = x * 2;
cout << x << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
我来回复