HDU 4054 - Hexadecimal View

先上一枚水题,模拟。

/*
ID:esxgx1
LANG:C++
PROG:hdu4054
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main(void)
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif

    char ascs[4097];

    while(cin.getline(ascs, 4097)) {
        int len = strlen(ascs);
        for(int i=0; i<len; i+=16) {
            printf("%04x: ", i);
            int t = 0;
            while(t<min(len-i, 16)) {
                printf("%02x", ascs[t++ +i]);
                if (!(t % 2)) putchar(‘ ‘);
            }
            while(t < 16) {
                printf("  "), ++t;
                if (!(t % 2)) putchar(‘ ‘);
            }
            t = 0;
            while(t<min(len-i, 16)) {
                if (ascs[t + i] >= ‘A‘ && ascs[t + i] <= ‘Z‘)
                    putchar(ascs[t + i] - ‘A‘ + ‘a‘);
                else if (ascs[t + i] >= ‘a‘ && ascs[t + i] <= ‘z‘)
                    putchar(ascs[t + i] - ‘a‘ + ‘A‘);
                else putchar(ascs[t + i]);
                ++t;
            }
            putchar(‘\n‘);
        }
    }
    return 0;
}
2014-07-28 19:12:58 Accepted 4054 15MS 316K 911 B G++

HDU 4054 - Hexadecimal View,布布扣,bubuko.com

时间: 2024-08-10 02:09:40

HDU 4054 - Hexadecimal View的相关文章

HDU 4054 Hexadecimal View 模拟

戳这里:HDU 4054 //复习一下 cin.getline() 的用法 1 #include "bits/stdc++.h" 2 using namespace std; 3 char str[5000]; 4 5 char Change(char c) 6 { 7 if('A' <= c && c <= 'Z') { 8 return c + 32; 9 } 10 if('a' <= c && c <= 'z') { 11

HDU 5880 Family View (AC自动机)

Family View Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Description Steam is a digital distribution platform developed by Valve Corporation offering digital rights management (DRM), multiplayer gaming and socia

hdu 4054 模拟 练习十六进制输出

http://acm.hdu.edu.cn/showproblem.php?pid=4054 貌似一般区域赛都会有一道水题 这道题PE了一次  因为输出每个数其实是两个位 如果用空格补齐的话  应该用两个空格 我用了一个空格,,, 学到: 1.%x  十六进制输出  可以输出整型,字符型等等 2.%02x  保证两位 而且会输出先导0的两位 //#pragma comment(linker, "/STACK:102400000,102400000") #include <cstd

HDU 5880 Family View

$AC$自动机. 用$AC$自动机匹配一次,开一个$flag$记录一下以$i$位置为结尾的最长要打$*$多少个字符,然后倒着扫描一次就可以输出了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector&g

HDU 5880 Family View (2016 青岛网络赛 C题,AC自动机)

题目链接  2016 青岛网络赛  Problem C 题意  给出一些敏感词,和一篇文章.现在要屏蔽这篇文章中所有出现过的敏感词,屏蔽掉的用$'*'$表示. 建立$AC$自动机,查询的时候沿着$fail$指针往下走,当匹配成功的时候更新$f[i]$ $f[i]$表示要屏蔽以第$i$个字母结尾的长度为$f[i]$的字符串. 原文地址:https://www.cnblogs.com/cxhscst2/p/8452147.html

ACM总结——dp专辑(转)

感谢博主——      http://blog.csdn.net/cc_again?viewmode=list       ----------  Accagain  2014年5月15日 动态规划一直是ACM竞赛中的重点,同时又是难点,因为该算法时间效率高,代码量少,多元性强,主要考察思维能力.建模抽象能力.灵活度. 本人动态规划博客地址:http://blog.csdn.net/cc_again/article/category/1261899 ***********************

【DP专辑】ACM动态规划总结

转载请注明出处,谢谢.   http://blog.csdn.net/cc_again?viewmode=list          ----------  Accagain  2014年5月15日 动态规划一直是ACM竞赛中的重点,同时又是难点,因为该算法时间效率高,代码量少,多元性强,主要考察思维能力.建模抽象能力.灵活度. 本人动态规划博客地址:http://blog.csdn.net/cc_again/article/category/1261899 ******************

(转)dp动态规划分类详解

dp动态规划分类详解 转自:http://blog.csdn.NET/cc_again/article/details/25866971 动态规划一直是ACM竞赛中的重点,同时又是难点,因为该算法时间效率高,代码量少,多元性强,主要考察思维能力.建模抽象能力.灵活度. ****************************************************************************************** 动态规划(英语:Dynamic programm

这个是转的。学完就删_(:з」∠)_

原文链接:http://blog.csdn.net/cc_again/article/details/25866971 好多dp:http://blog.csdn.net/cc_again/article/category/1261899 一.简单基础dp 这类dp主要是一些状态比较容易表示,转移方程比较好想,问题比较基本常见的.主要包括递推.背包.LIS(最长递增序列),LCS(最长公共子序列),下面针对这几种类型,推荐一下比较好的学习资料和题目. 1.递推: 递推一般形式比较单一,从前往后,