fork download
  1. #include<iostream>
  2. using namespace std;
  3. int d[100][10];
  4. int main(){
  5. int n;
  6. int mod=1000000000;
  7. cin>>n;
  8. d[1][0]=0;
  9. for(int i=1;i<10;i++){
  10. d[1][i]=1;
  11. }
  12. for(int i=2;i<=n;i++){
  13. for(int j=0;j<10;j++){
  14. if(j==0) d[i][j]=d[i-1][j+1]%mod;
  15. if(j==9) d[i][j]=d[i-1][j-1]%mod;
  16. d[i][j]=(d[i-1][j-1]%mod+d[i-1][j+1]%mod)%mod;
  17. }
  18. }
  19. int ans=0;
  20. for(int i=0;i<10;i++){
  21. ans=(ans+d[n][i]%mod)%mod;
  22. }
  23. cout<<ans;
  24. return 0;
  25. }
Success #stdin #stdout 0s 4312KB
stdin
2
stdout
18