Advertisement
FuFsQ

fb

Sep 27th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. #define fora(x) for(auto &I : x)
  8. #define rfor(x) for(int I = x.size()-1; I >= 0; I--)
  9.  
  10. void getMinFibseries(vector<int> &Fib, int N){
  11.     int F1 = 0, F2 = 0, F3 = 1, i = 0;
  12.  
  13.     while(N > F3)
  14.     {
  15.         F1 = F2;
  16.         F2 = F3;
  17.         F3 = F1 + F2;
  18.  
  19.         Fib.push_back(F3);
  20.     }
  21.  
  22.     if(Fib.back() > N)
  23.         Fib.pop_back();
  24. }
  25.  
  26. int main()
  27. {
  28.     vector<int> Fs;
  29.     vector<int> Rt;
  30.  
  31.     int N;
  32.     scanf("%d",&N);
  33.  
  34.     getMinFibseries(Fs,N);
  35.     Rt = vector<int>(Fs.size()-1,0);
  36.     Rt.push_back(1);
  37.  
  38.     int delta = N;
  39.     for(int i = Fs.size()-1; i >= 0; i--)
  40.     {
  41.         if(Fs[i] <= delta){
  42.             delta -= Fs[i];
  43.             Rt[i] = 1;
  44.         }
  45.  
  46.  
  47.         if(delta == 0)
  48.             break;
  49.     }
  50.  
  51.     rfor(Rt)
  52.         printf("%d",Rt[I]);
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement