Problem Description
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 3n lowercase letter.The binary ascii string of s is a string consist of 83n 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 83*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

题目大意是说,给你一个字符串,先把字符串中的每个字母转换为对应的ascll码,再将ascll码转化为八位二进制形式,连起来后从头开始一次取六位,将这六位转化为十进制数,输出即可,主要在于这个转化的过程,用一个temp数组接收每次转换的数字,再在总的数组中存储起来。注意好过程的细节就比较好做。题目坑点在于最后一个输出后面有一个空格。

AC代码

#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int bina[5000005];
int main()
{string s;cin>>s;int i,j,k=0,len=s.length(),temp[8];for(i=0;i<len;i++){int t=(int)s[i];memset(temp,0,sizeof(temp));j=0;while(t){temp[j]=t&1;t>>=1;j++;}for(j=0;j<8;j++)bina[k++]=temp[j];}int ans=0;for(i=0;i<k;i++){if(i%6==0&&i){cout<<ans<<" ";ans=0;}ans+=bina[i]*pow(2,5-i%6);}cout<<ans<<" ";return 0;
}

Coding Problem 模拟相关推荐

  1. bitset HDU6515 Coding Problem

    Coding Problem [ HDU - 6515 ] 题目大意:给你一个字符串,每个字母的ASCII二级制颠倒过来组成一个01数组. 然后这个数组每六位组成一个数字的ASCII输出 一道模拟题, ...

  2. Boring data structure problem 模拟-双端队列

    题意 : 维护一个"双端队列",1e7次操作,支持左插入,右插入,按值删除,查找中点(靠右)值ceil[(m+1)/2]ceil[(m + 1) / 2]ceil[(m+1)/2] ...

  3. 【HNOI2003】【BZOJ1216】操作系统(模拟,优先队列)

    problem 模拟操作系统的进程调度 给定每一个进程的进程号,到达时间,执行时间和运行优先级.(已经按到达时间从小到大排序) 如果一个进程到达的时候CPU是空闲的,则它会一直占用CPU直到该进程结束 ...

  4. python模拟登录163邮箱_python模拟登陆163邮箱并下载邮件内容(第三版代码片段)

    python模拟登陆163邮箱并下载邮件内容(第三版代码片段) 注意: 1 由于163邮箱有众多版本,所以登录请求URL,邮件URL等可能也不太一样,下面是163的简约3.0 2 代码缺乏错误处理能力 ...

  5. python实现翻_python实现模拟按键,自动翻页看u17漫画

    python实现模拟按键,自动翻页看u17漫画 发布于 2015-10-22 08:23:25 | 134 次阅读 | 评论: 0 | 来源: 网友投递 Python编程语言Python 是一种面向对 ...

  6. 2019中山大学程序设计竞赛

    Problem A 题意:有一个长度为n的随机排列以及m个min.max操作.问最后一个操作的结果的期望 * n! 的结果. 题解: 枚举k,考虑计算结果 >= k 的排列有几个. 此时数字本质 ...

  7. 软件工程专业实习可以做什么_想要获得软件工程实习机会? 这里有一些想法可以帮助您...

    软件工程专业实习可以做什么 by Tatiana Doyle 塔蒂亚娜·道尔(Tatiana Doyle) 想要获得软件工程实习机会? 这里有一些想法可以帮助您. (Looking to land a ...

  8. 华夏常春藤_我如何在没有常春藤大学学位的情况下从微软,亚马逊和Twitter获取报价

    华夏常春藤 This is for those of you out there who are about to start your job search and who may be worri ...

  9. Turbo Autoencoder: Deep learning based channel code for point-to-point communication channels

    Turbo Autoencoder: Deep learning based channel code for point-to-point communication channels Abstra ...

最新文章

  1. usaco ★Agri-Net 最短网络
  2. 砂.随笔.三十二.Together forever and ever
  3. Linux服务器运行sh文件提示权限不够解决方法?飞腾服务器Permission denied问题授权方法
  4. ajax刷新iframe页面,通过iframe实现简单的ajax表单提交
  5. css怎么使元素绝对定位有过度效果_CSS定位属性Position实例分析
  6. java 保留字符串,如何在Java中保留字符串而不使用反转功能
  7. 【MSDN】正则表达式介绍
  8. 在一个软件开发项目中进行实际日程安排的十二点提示(转)
  9. TextView settextcolor 无效解决方案
  10. openCms安装技巧
  11. 无线桥接(副路由器连接主路由器,以实现WiFi范围扩大)
  12. 鸿蒙系统反应慢,系统优化非常的关键 鸿蒙2.0和iOS14的反应速度测试
  13. java ip搜索功能_局域网ip搜索工具扫描设备的简单Java实现
  14. java null==null是否成立
  15. CV学习笔记-VGG
  16. Python数据挖掘课程 五.线性回归知识及预测糖尿病实例
  17. 阿里研究院崔瀚文:“单身经济”背后的“新家园”
  18. xslt简介_XSLT简介
  19. sublime加动画css3,CSS3 Sublime 代码编辑器模拟
  20. 2.3-非平稳时间序列分析

热门文章

  1. Geoserver的ImageMosaic数据源添加以及服务发布
  2. IntelliJ IDEA 文件夹重命名--解决重命名后js文件引用找不到路径报404错误
  3. 在jsp中调用常量类中的属性值
  4. PreparedStatement.SetDate
  5. 【网络流24题】[CTSC1999]家园
  6. Java语言的特点和特性
  7. EJB Remote/Local 绑定和JNDI Lookup
  8. docker网络基础配置
  9. HDU 5680 zxa and set 水题
  10. Android日期格式化