我用大數乘法寫的
AC了,但是我想請問題目所說的 "<<" 運算子要怎麼用?
//===白字。防雷=================
#include <stdio.h>
#define MAX 10000000
#define BASE 10
int big[MAX];
int top;
void init () {
int i;
big[0] = 1;
for (i = 1; i < MAX; i++) {
big[i] = 0;
}
top = 1;
}
void print (int *a) {
int i;
for (i = MAX-1; i >= 0; i--) {
if (a[i] != 0) {
printf("%d", a[i]);
break;
}
}
i--;
for (; i >= 0; i--) {
printf("%d", a[i]);
}
puts("");
}
void times (int *a, int goal) {
int i, now;
for (now = 1; now <= goal; now++) {
for (i = 0; i < top; i++) {
a[i] *= 2;
}
for (i = 0; i < top - 1; i++) {
if (a[i] > BASE-1) {
a[i+1] += (a[i] / BASE);
a[i] %= BASE;
}
}
while (a[top-1] > BASE-1) {
a[top] += (a[top-1] / BASE);
a[top-1] %= BASE;
top++;
}
}
}
int main () {
int ans = 0;
init();
times(big, 1000);
// printf("2^%d = ", 1000);
// print(big);
int i;
for (i = 0; i <= top; i++) {
ans += big[i];
}
// puts("---------------------------");
printf("%d\n", ans);
// puts("---------------------------");
getchar();
return 0;
}