提交时间:2024-08-20 15:58:36

运行 ID: 169253

#include<bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); long long a[2]={0,9},b[2]={0,1}; for(int i=2;i<=n;i++) { a[i%2]=b[(i-1)%2]+9*a[(i-1)%2]; b[i%2]=a[(i-1)%2]+9*b[(i-1)%2]; } printf("%lld",a[n%2]-a[(n-1)%2]); return 0; }