大连区域赛的D题,最水的那个。
我用了50分钟写完这题,1Y,效率好低><。。。。模拟题啊,应该党擅长点。。
其他题没敢看。。。
不多说了,题意很好理解,看sample就行。。。
我还傻傻地写了个16进制转换。。好2.。。直接输出16进制就好了。。
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <iostream>
#define MID(x,y) ( ( x + y ) >> 1 )
#define L(x) ( x << 1 )
#define R(x) ( x << 1 | 1 )
#define FOR(i,s,t) for(int i=(s); i<(t); i++)
#define BUG puts("here!!!")
#define STOP system("pause")
#define file_r(x) freopen(x, "r", stdin)
#define file_w(x) freopen(x, "w", stdout)
using namespace std;
const int MAX = 5000;
char s[MAX];
int main()
{
while( gets(s) )
{
int len = strlen(s);
int cnt = 0;
FOR(i, 0, len)
{
if( i % 16 == 0 )
{
if( i != 0 )
printf("\n");
int p = cnt * 16;
printf("%04x:", p);
cnt++;
}
if( i % 2 == 0 )
printf(" ");
printf("%x",s[i]);
if( (i+1) % 16 == 0 )
{
printf(" ");
FOR(k, i-15, i+1)
{
if( isalpha(s[k]) )
if( islower(s[k]) )
s[k] = toupper(s[k]);
else
s[k] = tolower(s[k]);
printf("%c", s[k]);
}
}
}
if( len % 16 )
{
int l = (len % 16)/2 + len % 16 * 2;
if( len % 16 % 2 != 0 )
l++;
int kong = 40 - l;
FOR(i, 0, kong+1)
printf(" ");
int a = len % 16;
FOR(i, len-a, len)
{
if( isalpha(s[i]) )
if( islower(s[i]) )
s[i] = toupper(s[i]);
else
s[i] = tolower(s[i]);
printf("%c", s[i]);
}
}
printf("\n");
}
return 0;
}