Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<string>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. ifstream read;
  9. ofstream write;
  10. read.open("input.txt");
  11. write.open("output.txt");
  12.  
  13. int N,pos;
  14.  
  15. for(int i=0;i<3;i++){
  16. read>>N;
  17. int A[N];
  18. int B[N]={0};
  19. A[0]=1;
  20. A[1]=2;
  21. for(int j=2;j<N;j++){
  22. A[j]=A[j-1]+A[j-2];
  23. if(A[j]>=N){
  24. pos=j;
  25. break;
  26. }
  27. }
  28. for(int j=pos;N!=0;j--)
  29. if(A[j]<=N){
  30. N-=A[j];
  31. B[j]=1;
  32. }
  33.  
  34. for(int j=0;j<pos;j++) write<<B[j];
  35. write<<endl;
  36. }
  37.  
  38. read.close();
  39. write.close();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement