fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n;
  6. long long f[100];
  7.  
  8. int main()
  9. {
  10. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  11. freopen("SUMFIBO.INP", "r", stdin);
  12. freopen("SUMFIBO.OUT", "w", stdout);
  13. cin >> n;
  14. f[0] = 0;
  15. f[1] = 1;
  16. int i = 2;
  17. while (f[i-1] + f[i-2] <= 1e9) f[i] = f[i-1] + f[i-2], i++;
  18. i--;
  19. for (int j = i; j > 0; j--)
  20. if (f[j] <= n) cout << f[j] << ' ', n-=f[j];
  21. }
  22.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty