Thursday 1 December 2016

Solution of URI 2292 :: LED Panel


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>

int main()
{
    int tst, i;
    scanf("%d", &tst);
    while(tst--)
    {
        long long int num, dcml = 0ll, tmp;
        char str[65];
        scanf("%s %lld", str, &num);
        for(i=0; str[i]; i++)
        {
            if(str[i]=='O')
                dcml += ceil(pow(2, i));
        }
        int lnth = strlen(str);
        tmp = ceil(pow(2, lnth));
        dcml += num;
        dcml = dcml % tmp;
        tmp = dcml;
        while(tmp)
        {
            if(tmp%2ll) printf("O");
            else printf("X");
            tmp /= 2ll;
        }
        tmp = log2(dcml) + 1ll;
        for(i=lnth - tmp; i>=1; i--)
            printf("X");
        printf("\n");
    }
    return 0;
}

3 comments:

  1. Locação de Painel de Led em São Paulo. Projetosespeciais oferecer comprar e locação o melhor painéis led, iluminação, som e vários outros produtos para o seu

    For more information visit here==>> https://projetosespeciais.com/

    ReplyDelete
  2. Comprar Painel de Led
    A Projetos Especiais oferece o que há de melhor em: Locação de Painel de Led, Locação de Palcos, Iluminação, Som e dentre outros. Acesse o nosso site!

    ReplyDelete

Note: only a member of this blog may post a comment.