Secret 【弱省胡策】Round #7
数据下载地址已更新
背景
wys是TKD的妹子。
wys听说TKD总把题面写得很长很长;
于是这一次她要求TKD把题面写得很短很短。
描述
这次的题面是有故事的>w<
有一天,TKD给wys发了一份密码,然后就默默地去码题了;
wys当然很不理解啊,发一串密码是个啥玩意儿;
然后呢,TKD很良心地给wys发了一份解密程序;
于是wys就能成功看懂了TKD发的东西了!
但是wys还是不满足,
她还想知道TKD是怎样把字符串加密的,
wys发现自己想不出来,所以想请你来帮帮她的忙。
帮wys写出加密程序的话,wys是会给你奖励的哦~
输入格式
第一行一个整数表示数据编号
接下来四行表示每一组数据的四个字符串。
输出格式
第一行一个整数表示数据编号
接下来四行表示每一组数据加密之后的密文。
TKD一共有五种加密方法,每种加密方法有10组数据。
wys已经收集到了全部的字符串,但是密文只收集到了一半。
即给选手的明文和输入文件完全相同(5行),密文只有输出文件中密文的一半(3行)。
提示
密文的格式是由若干个01串组成的;
01串的长度固定为8,两个01串之间用一个空格隔开;
每一个01串代表一个二进制数字;
也就是说这5种加密都是字符串→数字串的加密方式;
因为8位01串代表的是0~255之间的数,所以也可以理解为字符串→字符串的加密方式。
另外输入的字符串全部由字母数字空格以及常用字符&标点符号组成,不包括\0和\n。
对于给出的加密程序模板,
保证只会调用一次Srand();
保证不会调用无用的Rand();
不保证Len不变;
不保证交换两行输入字符串的顺序,得到的密文和原来一样;
即一个字符串对应的密文可能和上一个字符串有关;
并且仅可能和自己以及上一个字符串有关。
加密程序模板
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> using namespace std; void _gets(char *UseS) { gets(UseS); static int Len_of_U; Len_of_U=strlen(UseS); if(UseS[Len_of_U-1]=='\r') UseS[Len_of_U-1]=0; } namespace Random_Number { unsigned Seed; void Srand(unsigned GetSeed) { Seed=GetSeed; } unsigned Rand(void) { Seed=Seed*1103515245+12345; return (Seed/65536)%32768; } } namespace Case0 { unsigned char GetC[_L]; void Print(unsigned char Out) { static bool Save[8]; for(int i=0;i<8;i++) { if(Out&1) Save[i]=true; else Save[i]=false; Out>>=1; } for(int i=7;i>=0;i--) if(Save[i]) printf("1"); else printf("0"); } void Main() { static int Len; for(int Now=0;Now<4;Now++) { _gets((char*)GetC); Len=strlen((char*)GetC); ... for(int i=0;i<Len;i++) Print(GetC[i]),printf("%c",i^(Len-1)?' ':'\n'); } } } namespace Case1 { unsigned char GetC[_L]; void Print(unsigned char Out) { static bool Save[8]; for(int i=0;i<8;i++) { if(Out&1) Save[i]=true; else Save[i]=false; Out>>=1; } for(int i=7;i>=0;i--) if(Save[i]) printf("1"); else printf("0"); } void Main() { static int Len; for(int Now=0;Now<4;Now++) { _gets((char*)GetC); Len=strlen((char*)GetC); ... for(int i=0;i<Len;i++) Print(GetC[i]),printf("%c",i^(Len-1)?' ':'\n'); } } } namespace Case2 { unsigned char GetC[_L]; void Print(unsigned char Out) { static bool Save[8]; for(int i=0;i<8;i++) { if(Out&1) Save[i]=true; else Save[i]=false; Out>>=1; } for(int i=7;i>=0;i--) if(Save[i]) printf("1"); else printf("0"); } void Main() { static int Len; for(int Now=0;Now<4;Now++) { _gets((char*)GetC); Len=strlen((char*)GetC); ... for(int i=0;i<Len;i++) Print(GetC[i]),printf("%c",i^(Len-1)?' ':'\n'); } } } namespace Case3 { unsigned char GetC[_L]; void Print(unsigned char Out) { static bool Save[8]; for(int i=0;i<8;i++) { if(Out&1) Save[i]=true; else Save[i]=false; Out>>=1; } for(int i=7;i>=0;i--) if(Save[i]) printf("1"); else printf("0"); } void Main() { static int Len; for(int Now=0;Now<4;Now++) { _gets((char*)GetC); Len=strlen((char*)GetC); ... for(int i=0;i<Len;i++) Print(GetC[i]),printf("%c",i^(Len-1)?' ':'\n'); } } } namespace Case4 { unsigned char GetC[_L]; void Print(unsigned char Out) { static bool Save[8]; for(int i=0;i<8;i++) { if(Out&1) Save[i]=true; else Save[i]=false; Out>>=1; } for(int i=7;i>=0;i--) if(Save[i]) printf("1"); else printf("0"); } void Main() { static int Len; for(int Now=0;Now<4;Now++) { _gets((char*)GetC); Len=strlen((char*)GetC); ... for(int i=0;i<Len;i++) Print(GetC[i]),printf("%c",i^(Len-1)?' ':'\n'); } } } int main() { int Case; Random_Number::Srand(1); scanf("%d",&Case); static char Empty[10]; gets(Empty); printf("%d\n",Case); Case/=10; if(Case==0) Case0::Main(); if(Case==1) Case1::Main(); if(Case==2) Case2::Main(); if(Case==3) Case3::Main(); if(Case==4) Case4::Main(); return 0; }
样例下载密码: ezv1
数据下载密码: c5y8