HOJ 1012 Decoding Task
要注意两点:
这道题没说多组数据其实有多组数据,
这道题卡内存。
英文比较难读,但是题还是比较简单的。
用b1异或32可以得到第一位的密匙,
用密匙异或a1可以得到明文的第一位,
然后这样异或下来就可以了
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=10001;
inline int cread(){
int ch=getchar();
while((ch<'0'||ch>'9')&&(ch<'A'||ch>'F')&&ch!='\n'){
if(ch==EOF) return -2;
ch=getchar();
}
if(ch=='\n') return -1;
if(ch>='0'&&ch<='9') return ch-'0';
return ch-'A'+10;
}
short a[N],len;
int main(){
int x=cread(),y;
while(x!=-2){
len=0;
while(1){
if(x==-1) break;
y=cread();
a[len++]=x*16+y;
x=cread();
}
int ex=32;
for(int i=0;i<=len;i++){
x=cread(),y=cread();
int b=x*16+y;
ex=b^ex;
printf("%02X",ex);
ex=ex^a[i];
}
puts("");
x=cread();
while(x==-1) x=cread();
}
return 0;
}

浙公网安备 33010602011771号