斯诺登的密码

来源:互联网 发布:java udp函数 编辑:程序博客网 时间:2024/05/17 15:36

题目背景

根据斯诺登事件出的一道水题

题目描述

题目描述

2013年X月X日,俄罗斯办理了斯诺登的护照,于是他混迹于一架开往委内瑞拉的飞机。但是,这件事情太不周密了,因为FBI的间谍早已获悉他的具体位置——但这不是最重要的——最重要的是如果要去委内瑞拉,那么就要经过古巴,而经过古巴的路在美国的掌控之中。丧心病狂的奥巴马迫降斯诺登的飞机,搜查时却发现,斯诺登杳无踪迹。但是,在据说是斯诺登的座位上,发现了一张纸条。纸条由纯英文构成:Obama is a two five zero.(以"."结束输出,只有6个单词+一个句号,句子开头如没有大写亦为合法)这句话虽然有点无厘头,但是警官陈珺骛发现这是一条极其重要的线索。他在斯诺登截获的一台笔记本中找到了一个C++程序,输入这条句子后立马给出了相对应的密码。陈珺鹜高兴得晕了过去,身为警官的你把字条和程序带上了飞机,准备飞往曼哈顿国际机场,但是在飞机上检查的时候发现——程序被粉碎了!飞机抵达华盛顿只剩5分钟,你必须在这5分钟内编写(杜撰)一个程序,免受上司的10000000000%10大板。破译密码的步骤如下:

(1)找出句子中所有用英文表示的数字(≤20),列举在下:

正规:one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty

非正规:a both another first second third

(2)将这些数字平方后%100,如00,05,11,19,86,99。

(3)把这些两位数按数位排成一行,组成一个新数,如果开头为0,就去0。

(4)找出所有排列方法中最小的一个数,即为密码。

// 数据已经修正 By absi2011 如果还有问题请联系我

输入输出格式

输入格式:

一个含有6个单词的句子。

输出格式:

一个整型变量(密码)。

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int a,b,c,d,e,f,g,cnt;int z[104];char x[7][15];int main(){for(a=1;a<=6;a++){cin>>x[a];b=strlen(x[a]);for(c=0;c<=b-1;c++){if(x[a][c]>='A'&&x[a][c]<='Z'){x[a][c]=x[a][c]+32;}}if(b==1){if(x[a][0]=='a'){cnt++;z[cnt]=1;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}if(b==3){if(x[a][0]=='o'&&x[a][1]=='n'&&x[a][2]=='e'){cnt++;z[cnt]=1;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='t'&&x[a][1]=='w'&&x[a][2]=='o'){cnt++;z[cnt]=2;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='s'&&x[a][1]=='i'&&x[a][2]=='x'){cnt++;z[cnt]=6;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='t'&&x[a][1]=='e'&&x[a][2]=='n'){cnt++;z[cnt]=10;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}if(b==4){if(x[a][0]=='f'&&x[a][1]=='o'&&x[a][2]=='u'&&x[a][3]=='r'){cnt++;z[cnt]=4;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='b'&&x[a][1]=='o'&&x[a][2]=='t'&&x[a][3]=='h'){cnt++;z[cnt]=2;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='f'&&x[a][1]=='i'&&x[a][2]=='v'&&x[a][3]=='e'){cnt++;z[cnt]=5;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='n'&&x[a][1]=='i'&&x[a][2]=='n'&&x[a][3]=='e'){cnt++;z[cnt]=9;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}if(b==5){if(x[a][0]=='t'&&x[a][1]=='h'&&x[a][2]=='r'&&x[a][3]=='e'&&x[a][4]=='e'){cnt++;z[cnt]=3;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='t'&&x[a][1]=='h'&&x[a][2]=='i'&&x[a][3]=='r'&&x[a][4]=='d'){cnt++;z[cnt]=3;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='f'&&x[a][1]=='i'&&x[a][2]=='r'&&x[a][3]=='s'&&x[a][4]=='t'){cnt++;z[cnt]=1;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='s'&&x[a][1]=='e'&&x[a][2]=='v'&&x[a][3]=='e'&&x[a][4]=='n'){cnt++;z[cnt]=7;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='e'&&x[a][1]=='i'&&x[a][2]=='g'&&x[a][3]=='h'&&x[a][4]=='t'){cnt++;z[cnt]=8;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}if(b==6){if(x[a][0]=='e'&&x[a][1]=='l'&&x[a][2]=='e'&&x[a][3]=='v'&&x[a][4]=='e'&&x[a][5]=='n'){cnt++;z[cnt]=11;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='s'&&x[a][1]=='e'&&x[a][2]=='c'&&x[a][3]=='o'&&x[a][4]=='n'&&x[a][5]=='d'){cnt++;z[cnt]=2;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='t'&&x[a][1]=='w'&&x[a][2]=='e'&&x[a][3]=='l'&&x[a][4]=='v'&&x[a][5]=='e'){cnt++;z[cnt]=12;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='t'&&x[a][1]=='w'&&x[a][2]=='e'&&x[a][3]=='n'&&x[a][4]=='t'&&x[a][5]=='y'){cnt++;z[cnt]=20;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}if(b==7){if(x[a][0]=='f'&&x[a][1]=='i'&&x[a][2]=='f'&&x[a][3]=='t'&&x[a][4]=='e'&&x[a][5]=='e'&&x[a][6]=='n'){cnt++;z[cnt]=15;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='a'&&x[a][1]=='n'&&x[a][2]=='o'&&x[a][3]=='t'&&x[a][4]=='h'&&x[a][5]=='e'&&x[a][6]=='r'){cnt++;z[cnt]=2;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='s'&&x[a][1]=='i'&&x[a][2]=='x'&&x[a][3]=='t'&&x[a][4]=='e'&&x[a][5]=='e'&&x[a][6]=='n'){cnt++;z[cnt]=16;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}if(b==8){if(x[a][0]=='t'&&x[a][1]=='h'&&x[a][2]=='i'&&x[a][3]=='r'&&x[a][4]=='t'&&x[a][5]=='e'&&x[a][6]=='e'&&x[a][7]=='n'){cnt++;z[cnt]=13;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='f'&&x[a][1]=='o'&&x[a][2]=='u'&&x[a][3]=='r'&&x[a][4]=='t'&&x[a][5]=='e'&&x[a][6]=='e'&&x[a][7]=='n'){cnt++;z[cnt]=14;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='e'&&x[a][1]=='i'&&x[a][2]=='g'&&x[a][3]=='h'&&x[a][4]=='t'&&x[a][5]=='e'&&x[a][6]=='e'&&x[a][7]=='n'){cnt++;z[cnt]=18;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}if(x[a][0]=='n'&&x[a][1]=='i'&&x[a][2]=='n'&&x[a][3]=='e'&&x[a][4]=='t'&&x[a][5]=='e'&&x[a][6]=='e'&&x[a][7]=='n'){cnt++;z[cnt]=19;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}if(b==9){if(x[a][0]=='s'&&x[a][1]=='e'&&x[a][2]=='v'&&x[a][3]=='e'&&x[a][4]=='n'&&x[a][5]=='t'&&x[a][6]=='e'&&x[a][7]=='e'&&x[a][8]=='n'){cnt++;z[cnt]=19;z[cnt]=z[cnt]*z[cnt];z[cnt]=z[cnt]%100;}}}sort(z+1,z+cnt+1);d=0;int lnt;for(c=1;c<=cnt;c++){if(z[c]!=0){if(z[c]<=9&&d==1){cout<<"0"<<z[c];lnt=1;}if(z[c]<=9&&d==0){d=1;cout<<z[c];lnt=1;}if(z[c]>=10){cout<<z[c];lnt=1;}}}if(lnt==0){cout<<"0";}//for(c=1;c<=cnt;c++)//{//cout<<z[c]<<endl;//}//cout<<z[1]<<z[2]<<z[3];//y='A';//z='a';//a=y;//b=z;//cout<<a<<b;}


原创粉丝点击