fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int a[n];
  8. a[0] = 1;
  9. a[1] = 1;
  10. for (int i = 2; i <= n; i++)
  11. {
  12. a[i] = (a[i - 1] + a[i - 2] + a[i - 3]) % 10;
  13. }
  14. cout << a[n];
  15. return 0;
  16. }
Success #stdin #stdout 0s 4404KB
stdin
Standard input is empty
stdout
1