E - Coding Problem HDU - 6515

Here is the logic.I am the brother of mata Chuang.Mata chuang is the brother of cxk.So what am I?Am I the grand-brother of cxk?Or am I in a position that same brother level of cxk?Or cxk is the grand-brother of me?
Fine,it doesn't matter to the problem.Problem can't be a problem until it has description.But description are just words.Meaningless words.So,we treat words miserably like this, given a string s consist of 3*n lowercase letter.The binary ascii string of s is a string consist of 8*3*n 0-1 string(one char,8bits,The lower significnt bit is in the front, the higher is in the back.). We want you output the binary ascii string.But we don't want the string too long.So we want you put every 6 bit together(The higher significnt bit is in the front, the lower is in the back.) and output the corresponding array,with a length of 8*3*n/6.Please check the sample for specific.

Input

one line,one string. (n<=1e5)

Output

one line,4*n integer representing the target array.

Sample Input

abc

Sample Output

33 36 27 6

        
  

Hint

s=abc
binary ascii string=10000110 01000110 11000110
answer binary array=100001 100100 011011 000110
final answer array=33 36 27 6
        
 
#include <bits/stdc++.h>

using namespace std;
    int vs[2400010];
int main()
{
    char s[300010];
    cin>>s;

    int len=strlen(s);
    int i,t=0;
    for(i=0;i<len;i++)
    {
        int a=(int)s[i];
        while(a)
        {
            vs[t++]=a%2;
            a=a/2;
        }
        vs[t++]=0;
    }
    for(i=0;i<t;i+=6)
    {
        int a=0;
        int c=1;
        for(int j=i+5;j>=i;j--)
        {
            a+=vs[j]*c;
            c*=2;
        }
            cout<<a<<" ";
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值