Advertisement
Saleh127

UVA 948

Sep 16th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. ll fiv[50]= {0};
  12. fiv[0]=1;
  13. fiv[1]=2;
  14. for(ll i=2; i<50; i++)
  15. {
  16. fiv[i]=fiv[i-1]+fiv[i-2];
  17. }
  18.  
  19. test
  20. {
  21. ll a,c,d,e,f,i,j=0;
  22. cin>>a;
  23. cout<<a<<" = ";
  24. for(i=49;i>=0;i--)
  25. {
  26. if(a/fiv[i]==1)
  27. {
  28. j=1;
  29. a=a%fiv[i];
  30. cout<<1;
  31. }
  32. else if(j==1)
  33. {
  34. cout<<0;
  35. }
  36. }
  37. cout<<" (fib)"<<endl;
  38. }
  39.  
  40.  
  41. return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement