document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. int input;
  8. int patterns[50]={0,1,2};
  9. int static soFarMaxLength = 2;
  10. int ans;
  11.  
  12. while(cin>>input){
  13. if(input==0){
  14. break;
  15. }
  16.  
  17. else if(input<=soFarMaxLength){
  18. ans = patterns[input];
  19. }
  20.  
  21. else{
  22. for(int i=soFarMaxLength+1; i<=input ; i++){
  23. patterns[i] = patterns[i-2] + patterns[i-1];
  24. }
  25. ans = patterns[input];
  26. soFarMaxLength = input;
  27. }
  28.  
  29.  
  30. cout<<ans<<endl;
  31. }
  32.  
  33.  
  34.  
  35. return 0;
  36. }
');