Sunday, 10 May 2015

UVA 11089 Fi-binary Number

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int kk=1, tc, n, m, fibo[50];
    string s;
    cin>>tc;
    fibo[0]=fibo[1]=1;
    for(int i=2;i<=45;i++)
        fibo[i]=fibo[i-1]+fibo[i-2];
    //cout<<fibo[45]<<endl;

    while(tc--)
    {
        cin>>n;
        //cout<<"Case "<<kk++<<": ";
        int pos=44;
        while(fibo[pos]>n) pos--;
        while(pos)
        {
            if(n>=fibo[pos])
            {
                cout<<"1";
                n-=fibo[pos];
            }
            else cout<<"0";
            pos--;
        }
        cout<<"\n";
    }

    return 0;
}

3 comments:

  1. Forex trading techniques alerts was what got me going in your way at last. A Forex trading working Binary Software strategy is a set of techniques that you use to company Forex trading dealing.

    ReplyDelete
  2. The Aussie Method is a 100% FREE software that will trade on the binary options markets with just 1 click! It's fully automated and places the winning trades for you!

    ReplyDelete
  3. কোড না দিয়া আইডিয়া আলোচনা করেন ডিটেইলসে। তাইলে মানুষের উপকার হবে। যে আইডিয়া বুঝে না, তারে কোড দেখায়ে লাভ কি? অনেকে কপি করে মেরে দিবে। আর এই কোড অনেক জায়গায় ই পাওয়া যায়।

    ReplyDelete