名字听起来十分厉害啊...一道lzz的提交答案题。

提答题,我们看看题目,给出一个解密程序,叫你加密。

每个点有一个加密的sample和一些要加密的文本。

从题目中我们可以得到一些信息:

加密后一般为8/16个一组,字符集|S|=95。

那就来看数据吧。

Data 1

奥妙重重...overwatch是什么鬼啊

咦第一行15个字符,加密完120个字符。怕是8位ascii?

写完一测,样例挂了。

然后去完那个解密器,随手输了8位,invalid output?但是sample确实是1位=>8位啊。

后面想想,可能只是一个映射,不一定是ascii,反正有sample。我真是傻逼

测了测sample,发现里面95个字符都有,然后就没有了。

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <stdlib.h>
  7. #include <string>
  8. #include <vector>
  9. #include <fstream>
  10. #include <set>
  11. #include <map>
  12. #include <queue>
  13. #include <algorithm>
  14. #include <sstream>
  15. #include <stack>
  16. #include <iomanip>
  17. using namespace std;
  18. map<char,string> mpp;
  19. int main()
  20. {
  21. ifstream fin("toodifficult1_simple.in");
  22. ifstream fin2("toodifficult1_simple.out");
  23. string s,s2;
  24. while(getline(fin,s))
  25. {
  26. getline(fin2,s2);
  27. int j=0;
  28. for(int i=0;i<s.length();i++)
  29. {
  30. string rp;
  31. for(int k=j;k<j+8;k++) rp.push_back(s2[k]);
  32. j+=8;
  33. mpp[s[i]]=rp;
  34. }
  35. }
  36. ifstream qwq("toodifficult1.in");
  37. freopen("toodifficult1.out","w",stdout);
  38. while(getline(qwq,s))
  39. {
  40. for(int i=0;i<s.length();i++) cout<<mpp[s[i]];
  41. putchar(10);
  42. }
  43. }

Data 2

咦那个aaaaa...aaaa怎么看起来这么鬼畜啊...怕是有什么肮脏的****。

似乎是二进制减一?数一数,似乎是16位一分割。

咦那个一串一串的16个1是啥啊...懵逼

然后我们拉到第一行最后...咦最后有一大坨1,数一数好像是25*16个1...

excited!似乎和字母有关。

好像这里思路就中断了...玩玩那个解密程序好了。

input:400个1 output:""

input:15个0+401个1 output:"a"

嗯这很正常。

input:16个1+15个0+385个1 output:"b"

咦,shenmegui,难道这是分割字母的?

input:15个0+17个1+15个0+385个1 output:Invalid

哦好像是下标?

input:15个0+17个1+14个0+1+0+384个1 output:"ab"

input:14个0+1+0+16个1+15个0+385个1 output:"ba"

后缀数组!不同开头的后缀中间插16个1!

那么我们只要写一个暴力就行了233

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <algorithm>
  7. #include <stdlib.h>
  8. #include <string>
  9. using namespace std;
  10. char s[233333];
  11. int rp[233333];
  12. bool cmp(int a,int b)
  13. {
  14. for(int x=0;;++x)
  15. {
  16. if(s[a+x]!=s[b+x]) return s[a+x]<s[b+x];
  17. }
  18. return 0;
  19. }
  20. int main()
  21. {
  22. freopen("toodifficult2.in","r",stdin);
  23. freopen("toodifficult2.out","w",stdout);
  24. string str;
  25. while(getline(cin,str))
  26. {
  27. strcpy(s,str.c_str());
  28. int n=str.size();
  29. for(int i=0;i<n;i++) rp[i]=i;
  30. sort(rp,rp+n,cmp);
  31. int cur='a';
  32. for(int i=0;i<n;i++)
  33. {
  34. int r=rp[i]+1,p=s[rp[i]];
  35. while(cur<p) printf("1111111111111111"), ++cur;
  36. int rs[16];
  37. for(int k=0;k<16;k++) rs[k]=r%2, r/=2;
  38. for(int k=15;k>=0;k--) putchar(rs[k]+48);
  39. }
  40. while(cur<'z') printf("1111111111111111"), ++cur;
  41. putchar(10);
  42. }
  43. }

Data 3

这输入是什么卵子啊...怎么这么乱啊...似乎是随机字符?

咦输出好像是64位啊...这是啥啊...是个整数?

咦输入可能也是整数?95进制?题目里还给了字符集?真刺激

S="a bcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,./\?;:'"<>[]{}()|-_=+*&^%$#@!`~"

试试95进制然后转二进制?看了看好像不太像。

然后就gg了。(接下来去看了题解

woc要把这些大数分解质因数!pollard-rho!

然后把小的因数放在前面输出就行了。

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <stdlib.h>
  7. #include <string>
  8. #include <vector>
  9. #include <set>
  10. #include <map>
  11. #include <queue>
  12. #include <algorithm>
  13. #include <sstream>
  14. #include <stack>
  15. #include <iomanip>
  16. using namespace std;
  17. char gg[2333];
  18. string S="a bcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,./\\?;:'\"<>[]{}()|-_=+*&^%$#@!`~";
  19. typedef long long ll;
  20. ll mul(ll a,ll b,ll n)
  21. {
  22. ll ans=0;
  23. while(b)
  24. {
  25. if(b&1) ans=ans+a, ans%=n;
  26. a=(a+a)%n; b>>=1;
  27. }
  28. return ans;
  29. }
  30. ll f(ll x,ll n)
  31. {
  32. return (mul(x,x,n)+1)%n;
  33. }
  34. ll gcd(ll a,ll b) {if(a<0) a=-a; if(b<0) b=-b; return b?gcd(b,a%b):a;}
  35. ll rho(ll n)
  36. {
  37. ll x=2, y=2, p=1;
  38. while(p==1)
  39. {
  40. x=f(x,n);
  41. y=f(f(y,n),n);
  42. p=gcd(x-y,n);
  43. }
  44. return p;
  45. }
  46. int main()
  47. {
  48. freopen("toodifficult3.in","r",stdin);
  49. freopen("toodifficult3.out","w",stdout);
  50. for(int i=0;i<S.size();i++) gg[S[i]]=i;
  51. string s;
  52. while(getline(cin,s))
  53. {
  54. long long r=0;
  55. for(int i=0;i<s.size();i++) r=r*95+gg[s[i]];
  56. ll a=rho(r),b=r/a;
  57. if(a>b) swap(a,b);
  58. int rs[32];
  59. for(int k=0;k<32;k++) rs[k]=a%2, a/=2;
  60. for(int k=31;k>=0;k--) putchar(rs[k]+48);
  61. for(int k=0;k<32;k++) rs[k]=b%2, b/=2;
  62. for(int k=31;k>=0;k--) putchar(rs[k]+48);
  63. putchar(10);
  64. }
  65. }

Data 4

太毒了...待补

Data 5

喂出题人!MD5是什么鬼啊!不是吧

咦说好MD5呢怎么sample的out里面全是10010啥的...

然后去玩checker,发现可以输入字符串啊!然后checker确实会返回正确的字符串md5。

咦,这01串怕是有什么交易...咦第一个点输出好像长得差不多...我把所有东西压成一行当第一个点丢给checker解密好了。

真刺激,以下是解密后的全文(人工换行):

As you know, it's too difficult to solve this case.

So I will give you some problems, you just need to answer them.

All of the answers of these problems only consist of lower-case letters and numbers.

No.1 What do I like to play?

No.2 There is a poem including these words "gouliguojiashengsiyi", and then?

No.3 Who wrote this poem?

We often call the Mobius function mu(n).f(n)=sum (i=1 to n) mu(i).

No.4 Please work out the minimum of f(n) when n belongs to [1,10^9].

No.5 Please work out the maximum of f(n) when n belongs to [1,10^9].

No.6 The last problems may be the most difficult problem of this contest.

Can you work out C(6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666,

2333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333) mod (1e100+7) ?

咦怎么只有6个问题...哦原来4和5两个问题分比较多。

No.1 overwatch(233

No.2 qiyinhuofubiquzhi(excited

No.3 jiangzemin(吃枣药丸

然后丢进checker一测,好像答案不对?md还要用第一题的那个加密程序啊

然后发现No.3 还是不对...后面想想好像是linzexu...(果然姿势水平不够高

接下来两个问题是什么卵子啊...梅滕斯函数的极值?我**怎么知道啊

暴力硬肛的话...除了空间都没什么问题。

额其实我们可以开三个bitset,每个10^9存质数和mu...

然后这样是过不了编译的...但是我们可以new...大概分配了4G内存,然后跑线筛,跑了200s,答案跑出来了...跑得电脑黑汗水流

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <algorithm>
  6. #include <iomanip>
  7. #include <time.h>
  8. #include <map>
  9. #include <bitset>
  10. using namespace std;
  11. #define MAXN 1000000000
  12. int *ps,pn=0;
  13. bitset<10000000001> np;
  14. bitset<10000000001> *hm_;
  15. bitset<10000000001> *ms_;
  16. void shai()
  17. {
  18. long long qzh=1;
  19. bitset<10000000001>&hm=*hm_;
  20. bitset<10000000001>&ms=*ms_;
  21. np[1]=1; hm[1]=1; ms[1]=1;
  22. long long maxn=1, minn=1;
  23. for(int i=2;i<=MAXN;i++)
  24. {
  25. if(!np[i]) {ps[++pn]=i; hm[i]=1; ms[i]=0;}
  26. for(int j=1;j<=pn&&ps[j]*i<=MAXN;j++)
  27. {
  28. int p=ps[j]*i; np[p]=1;
  29. if(i%ps[j]) hm[p]=hm[i], ms[p]=!ms[i];
  30. else {hm[p]=0; break;}
  31. }
  32. if(hm[i]) qzh+=(ms[i])?1:-1;
  33. maxn=max(maxn,qzh);
  34. minn=min(minn,qzh);
  35. if(i&131071);else cout<<i<<","<<minn<<","<<maxn<<" left"<<(1000000000*(clock()/(double)i)-clock())/1000.0<<"s\n";
  36. }
  37. cout<<minn<<","<<maxn<<"\n";
  38. }
  39. #define S2 80000000
  40. int main()
  41. {
  42. cout<<"准备分配"<<(sizeof(np)*3+sizeof(int)*S2)/1024.0/1024.0/1024.0<<"GB内存!\n";
  43. ps=new int[S2];
  44. cout<<"进度33%\n";
  45. hm_=new bitset<10000000001>();
  46. cout<<"进度66%\n";
  47. ms_=new bitset<10000000001>();
  48. cout<<"进度100%\n";
  49. shai();
  50. }

接下来No.6的话...woc这...如果电脑上没有python的话还是算了吧QAQ

......答案果然是no。

最后输出用的东西

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <stdlib.h>
  7. #include <string>
  8. #include <vector>
  9. #include <fstream>
  10. #include <set>
  11. #include <map>
  12. #include <queue>
  13. #include <algorithm>
  14. #include <sstream>
  15. #include <stack>
  16. #include <iomanip>
  17. using namespace std;
  18. map<char,string> mpp;
  19. int main()
  20. {
  21. ifstream fin("toodifficult1_simple.in");
  22. ifstream fin2("toodifficult1_simple.out");
  23. string s,s2;
  24. while(getline(fin,s))
  25. {
  26. getline(fin2,s2);
  27. int j=0;
  28. for(int i=0;i<s.length();i++)
  29. {
  30. string rp;
  31. for(int k=j;k<j+8;k++) rp.push_back(s2[k]);
  32. j+=8;
  33. mpp[s[i]]=rp;
  34. }
  35. }
  36. ifstream qwq("toodifficult5_u.out");
  37. freopen("toodifficult5.out","w",stdout);
  38. while(getline(qwq,s))
  39. {
  40. for(int i=0;i<s.length();i++) cout<<mpp[s[i]];
  41. putchar(10);
  42. }
  43. }

Q:不行啊,考场机子一共就不到4G内存,那个点怎么做啊wtf

A:暴搜啊...不是给了checker吗...反正答案估计就不是很大...随便搜搜

(UPD:刚才测了测暴搜,跑得十分的慢啊,就不贴上来了...而且还时不时出个bug啥的...不过如果在程序中直接内嵌一个算md5的代码应该会快很多把)

然后这样就有80分啦23333这提答真是刺激啊

toodifficult 题解的更多相关文章

  1. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  2. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  3. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  4. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  5. 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解

    题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...

  6. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  7. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

  8. 网络流n题 题解

    学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或 ...

  9. CF100965C题解..

    求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & ...

随机推荐

  1. 如何获取应用宝APP ID

    二百二维码支持绑定应用宝ID后,android 扫码下载后,微信直接下载APP,不打开应用宝页面,非常方便APP进行推广 那如何获取应用宝APP ID呢, 请参考下面的教程    一, 打开http: ...

  2. IOS开发证书显示“此证书的签发者无效”解决方法

    今天早上同事说咱们的证书无法使用了,显示“此证书的签发者无效”.一开始以为谁误操作了证书,查看后发现所有证书都无效了.查了会才发下原来是Apple Worldwide Developer Relati ...

  3. 关于tableview内cell自定义的注册以及创建

    自定义cell的方法主要有两种,storyboard以及xib(假设新建的是cellTableViewCell类) 比较倾向于xib方式使用xib在xib文件内将自定义的cell绘制好后导入到调用文件 ...

  4. sublime text 3 常用快捷键 、常用插件

    常用快捷键 查找( Ctrl + P ) 找到任何东西 - :+行号   定位到具体的行 - @+符号  js的函数名, css的选择器名 - #+关键字  定位到特定的关键字 命令面板 (Ctrl ...

  5. webapp设置适应pc和手机的页面宽高以及布局层叠图片文字

    <!DOCTYPE html> <html lang="zh-cn"> <head> <title>我趣旅行网-美剧迷</ti ...

  6. markdown学习笔记 (一)

    ##类Atx形式标题 # H1标题(一个井号加文字) ### H3标题(三个井号加文字) ###### H6标题(6个井号加文字) 类setext ======== 一级标题(下行加若干个等号) == ...

  7. sqlplus: error while loading shared libraries: /u01/app/lib/libclntsh.so.11.1

    成功安装了Oracle 11g后,使用sqlplus登录数据库时遇到下面错误: [oracle@DB-Server ~]$ sqlplus / as sysdba   sqlplus: error w ...

  8. Windows自动关机命令

    winxp中自带了自动关机功能,在开始→运行中使用SHUTDOWN命令 1. 延迟关机关机 shutdown -s -t 120 -s为关机:-t为时间,以秒为单位,120表示2分钟 表示两分钟后关机 ...

  9. HTML5游戏开发引擎,初识CreateJS

    CreateJS为CreateJS库,可以说是一款为HTML5游戏开发的引擎.打造 HTML5 游戏,构建新游戏,提供构建最新 HTML5 的技术.你可以通过这个网站学习如何构建跨平台和跨终端游戏.这 ...

  10. linux文件分发脚本

    1.说明 此脚本可分发两类文件,1.固定内容文件,2.(每台被分发主机)内容不同的文件 ppp.sh为拨号脚本,每台被分发主机内容不同 根据分发文件名字不同(ppp.sh和其他文件)自动选择分发方式 ...