HDOJ 4690 EBCDIC 模拟

把图片用ORC转化成文字,用vim录个宏很容易就可以字母们格式化.....

EBCDIC

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)

Total Submission(s): 811    Accepted Submission(s): 368

Problem Description

A mad scientist found an ancient message from an obsolete IBN System/360 mainframe. He believes that this message contains some very important secret about the Stein‘s Windows Project. The IBN System/360 mainframe uses Extended Binary Coded Decimal Interchange
Code (EBCDIC). But his Artificial Intelligence Personal Computer (AIPC) only supports American Standard Code for Information Interchange (ASCII). To read the message, the mad scientist ask you, his assistant, to convert it from EBCDIC to ASCII.

Here is the EBCDIC table.

Here is the ASCII table.

Input

The input of this problem is a line of uppercase hexadecimal string of even length. Every two hexadecimal digits stands for a character in EBCDIC, for example, "88" stands for ‘h‘.

Output

Convert the input from EBCDIC to ASCII, and output it in the same format as the input.

Sample Input

C59340D7A2A840C3969587999696

Sample Output

456C2050737920436F6E67726F6F

Hint

E.html download  方便图中文字复制
http://pan.baidu.com/share/link?shareid=453447595&uk=352484775

Author

Zejun Wu (watashi)

Source

2013 Multi-University Training Contest 9

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

map<string,int> mp;

string EBCDIC[10000]=
{"NUL","SOH","STX","ETX","  ","HT","  ","DEL","  ","  ","  ","VT","FF","CR","SO","SI",
"DLE","DC1","DC2","DC3","  ","  ","BS","  ","CAN","EM","  ","  ","IFS","IGS","IRS","IUS ITB",
"  ","  ","  ","  ","  ","LF","ETB","ESC","  ","  ","  ","  ","  ","ENQ","ACK","BEL",
"  ","  ","SYN","  ","  ","  ","  ","EOT","  ","  ","  ","  ","DC4","NAK","  ","SUB",
"SP","  ","  ","  ","  ","  ","  ","  ","  ","  ","  ",".","<","(","+","|",
"&","  ","  ","  ","  ","  ","  ","  ","  ","  ","!","$","*",")",";","  ",
"-","/","  ","  ","  ","  ","  ","  ","  ","  ","  ",",","%","_",">","?",
"  ","  ","  ","  ","  ","  ","  ","  ","  ","`",":","#","@","'","=","\"",
"  ","a","b","c","d","e","f","g","h","i","  ","  ","  ","  ","  ","  ",
"  ","j","k","l","m","n","o","p","q","r","  ","  ","  ","  ","  ","  ",
"  ","~","s","t","u","v","w","x","y","z","  ","  ","  ","  ","  ","  ",
"^","  ","  ","  ","  ","  ","  ","  ","  ","  ","[","]","  ","  ","  ","  ",
"{","A","B","C","D","E","F","G","H","I","  ","  ","  ","  ","  ","  ",
"}","J","K","L","M","N","O","P","Q","R","  ","  ","  ","  ","  ","  ",
"\\","  ","S","T","U","V","W","X","Y","Z","  ","  ","  ","  ","  ","  ",
"0","1","2","3","4","5","6","7","8","9","  ","  ","  ","  ","  ","  "};

string ASC[10000]=
{
"NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI",
"DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","IFS","IGS","IRS","IUS ITB",
"SP","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/",
"0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?",
"@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O",
"P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_",
"`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","DEL"
};

void init()
{
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<16;j++)
        {
            mp[ASC[i*16+j]]=i*16+j;
        }
    }
}

int num(char c)
{
    if(c>='0'&&c<='9')
        return c-'0';
    return c-'A'+10;
}

char CHAR(int x)
{
    if(x<=9) return x+'0';
    return x-10+'A';
}

int main()
{
    string READ;
    init();
    while(cin>>READ)
    {
        for(int i=0,sz=READ.size();i<sz;i+=2)
        {
            int c1=num(READ[i]),c2=num(READ[i+1]);
            string ck=EBCDIC[c1*16+c2];
            int id=mp[ck];
            printf("%c%c",CHAR(id/16),CHAR(id%16));
        }
        putchar(10);
    }
    return 0;
}
时间: 2025-01-02 05:27:43

HDOJ 4690 EBCDIC 模拟的相关文章

HDOJ 5071 Chat 模拟

大模拟: 1>saygoodbye要先对 always on top 的人说 2>对没有说过话的不要说good bye 3>用long long Chat Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 337    Accepted Submission(s): 82 Problem Description As ever

HDOJ 5353 Average 模拟

各种情况特判,然后枚举前两个点之间的关系 Average Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1723    Accepted Submission(s): 438 Special Judge Problem Description There are n soda sitting around a round tabl

hdoj 5319 Painter(模拟题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5319 思路分析:假设颜色R表示为1,颜色B表示为2,颜色G表示为3,因为数据量较小,采用暴力解法即可,即每次扫描对角线,看每条对角线需要画多少笔,统计所有对角线的笔数和即可: 代码如下: #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int MAX_N

HDOJ 2317. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of

模拟 HDOJ 4552 Running Rabbits

题目传送门 1 /* 2 模拟:看懂题意,主要是碰壁后的转向,笔误2次 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstring> 7 #include <vector> 8 using namespace std; 9 10 const int MAXN = 1e3 + 10; 11 const int INF = 0x3f3f3f3f; 12 struct Rabbit 13

模拟 HDOJ 5387 Clock

题目传送门 1 /* 2 模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在0~180内:小时13点以后和1以后是一样的(24小时) 3 模拟题伤不起!计算公式在代码内(格式:hh/120, mm/120, ss/120) 4 */ 5 /************************************************ 6 * Author :Running_Time 7 * Created Time :2015-8-13 13:04:31 8 * Fil

HDOJ 题目5097 Page Rank(矩阵运算,模拟)

Page Rank Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others) Total Submission(s): 280    Accepted Submission(s): 75 Problem Description Evaluation and rank of web pages is a hot topic for many internet companies and

hdoj 5131 Song Jiang&#39;s rank list 【模拟】

Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 653    Accepted Submission(s): 323 Problem Description <Shui Hu Zhuan>,also <Water Margin>was written by Shi Nai'

模拟+思维 HDOJ 5319 Painter

题目传送门 1 /* 2 题意:刷墙,斜45度刷红色或蓝色,相交的成绿色,每次刷的是连续的一段,知道最终结果,问最少刷几次 3 模拟+思维:模拟能做,网上有更巧妙地做法,只要前一个不是一样的必然要刷一次,保证是最小的,脑洞大 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 using namespace std; 10 11 c