提交时间:2024-08-21 10:18:51
运行 ID: 175694
#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\n",a[n%2]-a[(n-1)%2]); return 0; }