意思是把一行字符串的长度按照找7位一个字节输出,如果长度能够存在7位里,字节的最高位置0,否则只输出7位并且输出字节的最高位置1,直到全部输出长度.

要注意的是有空串要输出00,其他按照16进制输出就可以了,注意要补0.

 #include <cstdio>
#include <cstring>
using namespace std;
char a[];
int main(){
int T;
scanf("%d", &T);
getchar();
while(T--){
gets(a);
int len = strlen(a);
if(len == ) printf("");
while(len){
int t = len % ;
len /= ;
if(len) t += ;
printf("%02X", t);
}
len = strlen(a);
for(int i = ; i < len; ++i)
printf("%02X", a[i]);
printf("\n");
}
}

In 7-bit


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Very often, especially in programming contests, we treat a sequence of non-whitespace characters as a string. But sometimes, a string may contain whitespace characters or even be empty. We can have such strings quoted and escaped to handle these cases. However, a different approach is putting the length of the string before it. As most strings are short in practice, it would be a waste of space to encode the length as a 64-bit unsigned integer or add a extra separator between the length and the string. That's why a 7-bit encoded integer is introduced here.

To store the string length by 7-bit encoding, we should regard the length as a binary integer. It should be written out by seven bits at a time, starting with the seven least-significant (i.e. 7 rightmost) bits. The highest (i.e. leftmost) bit of a byte indicates whether there are more bytes to be written after this one. If the integer fits in seven bits, it takes only one byte of space. If the integer does not fit in seven bits, the highest bit is set to 1 on the first byte and written out. The integer is then shifted by seven bits and the next byte is written. This process is repeated until the entire integer has been written.

With the help of 7-bit encoded integer, we can store each string as a length-prefixed string by concatenating its 7-bit encoded length and its raw content (i.e. the original string).

Input

There are multiple test cases. The first line of input is an integer T indicating the number of test cases.

Each test case is simply a string in a single line with at most 3000000 characters.

Output

For each test case, output the corresponding length-prefixed string in uppercase hexadecimal. See sample for more details.

Sample Input

3
42
yukkuri shiteitte ne!!!
https://en.wikipedia.org/wiki/Answer_to_Life,_the_Universe,_and_Everything#Answer_to_the_Ultimate_Question_of_Life.2C_the_Universe_and_Everything_.2842.29

Sample Output

023432
1779756B6B75726920736869746569747465206E65212121
9A0168747470733A2F2F656E2E77696B6970656469612E6F72672F77696B692F416E737765725F746F5F4C6966652C5F7468655F556E6976657273652C5F616E645F45766572797468696E6723416E737765725F746F5F7468655F556C74696D6174655F5175657374696F6E5F6F665F4C6966652E32435F7468655F556E6976657273655F616E645F45766572797468696E675F2E323834322E3239

最新文章

  1. Spring AOP深入剖析
  2. C语言拾遗
  3. C#图像处理
  4. 前端见微知著工具篇:Bower组件管控
  5. 修改windows系統下xampp中apache端口被其他程式占用的問題
  6. C#学习笔记(七)——定义类
  7. NFC(5)编写NFC程序的基本步骤
  8. HDU 5700 区间交 线段树暴力
  9. Vagrant网络配置
  10. AngularJS:何时应该使用Directive、Controller、Service?【新手必看】
  11. c#获取页面重定向url
  12. 【Java每日一题】20170113
  13. C#之Message(转)
  14. 3-sum问题
  15. go-mysql,一个易用的mysql接口框架实现
  16. LevelDB源码分析-Bloom Filter
  17. Spring @RequestParam、@RequestBody和@ModelAttribute区别
  18. Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others
  19. Java 支付宝支付,退款,单笔转账到支付宝账户(支付宝订单退款)
  20. Sprint--5.21

热门文章

  1. 【视频教程】JEECG 入门视频教程大全+历史版本号代码下载
  2. Intellij IDEA创建Maven Web项目
  3. c# 获取指定目录下的所有文件并显示在网页上
  4. Java代码优化策略
  5. LeetCode 二叉树的最小深度
  6. 杭电ACM 素数判定
  7. php随笔5-thinkphp OA系统 人力资源管理
  8. 6月10日-IOS应用-日记本
  9. win32多线程程序设计笔记(第四章下)
  10. CPU指令的流水线运行