刘谦 • 2年前
typedef long long LL; using namespace std;
int n; int a[105][105], b[105][105];
void mul(int ans[], int c[], int d[]){
for (int i = 1; i <= c[0]; i++){
ans[i] += c[i] * 9;
if(ans[i] > 9){
ans[i + 1] += ans[i] / 10;
ans[i] %= 10;
}
}
int len = c[0];
while(ans[len + 1]) len++;
for (int i = 1; i <= d[0]; i++){
ans[i] += d[i];
if(ans[i] > 9){
ans[i + 1]++;
ans[i] -= 10;
}
}
len = max(len, d[0]);
while(ans[len + 1]) len++;
ans[0] = len;
}
int main() {
scanf("%d", &n);
a[1][0] = 1, a[1][1] = 9;
b[1][0] = 1, b[1][1] = 1;
for (int i = 2; i <= n; i++){
mul(a[i], a[i - 1], b[i - 1]);
mul(b[i], b[i - 1], a[i - 1]);
}
for (int i = 1; i <= a[n][0]; i++){
a[n][i] -= a[n - 1][i];
if(a[n][i] < 0){
a[n][i] += 10;
int t = i + 1;
while(a[n][t] == 0){
a[n][t] = 9;
t++;
}
a[n][t]--;
}
if(i == a[n - 1][0]) break;
}
int len = a[n][0];
while(a[n][len] == 0) len--;
for (int i = len; i >= 1; i--) printf("%d", a[n][i]);
printf("\n");
return 0;
} /**/
评论:
请先登录,才能进行评论