山东省第二届ACM大学生程序设计竞赛 Crack Mathmen 打表 模拟
来源:互联网 发布:淘宝卖家怎么处理差评 编辑:程序博客网 时间:2024/06/05 08:28
Crack Mathmen
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
For example, if they choose n = 2 and the message is "World" (without quotation marks), they encode the message like this:
1. the first character is 'W', and it's ASCII code is 87. Then f(′W′) = 87^2 mod 997 = 590.
2. the second character is 'o', and it's ASCII code is 111. Then f(′o′) = 111^2 mod 997 = 357.
3. the third character is 'r', and it's ASCII code is 114. Then f(′r′) = 114^2 mod 997 = 35. Since 10 <= f(′r′) < 100, they add a 0 in front and make it 035.
4. the forth character is 'l', and it's ASCII code is 108. Then f(′l′) = 108^2 mod 997 = 697.
5. the fifth character is 'd', and it's ASCII code is 100. Then f(′d′) = 100^2 mod 997 = 30. Since 10 <= f(′d′) < 100, they add a 0 in front and make it 030.
6. Hence, the encrypted message is "590357035697030".
One day, an encrypted message a mathman sent was intercepted by the human being. As the cleverest one, could you find out what the plain text (i.e., the message before encryption) was?
输入
输出
示例输入
3259035703569703000010010010010011000000000001001001001001
示例输出
WorldNo SolutionNo Solution
提示
来源
山东省第二届ACM大学生程序设计竞赛
给你加密的方式
我们可以打表处理所有的结果然后输出就行
一开始以为只有对字母加密然后无限wa
ACcode:
#include <iostream>#include <cstdio>#include <cstring>#include <string>#define maxn 10000005#define mod 997#define ll long longusing namespace std;char s[maxn];char has[1000];char ans[1234567];bool flag;int pow_mod(int x,int n){int res=1;x=x%mod;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;}return res;}bool init(int n){ memset(has,'\0',sizeof(has)); char aaa; for(int i=32;i<=126;++i){ aaa=i; int id=pow_mod(i,n); if(has[id]!='\0')return false; has[id]=aaa; } return true;}int main(){ int loop,n; scanf("%d",&loop); while(loop--){ scanf("%d",&n); scanf("%s",s); flag=true; flag=init(n); if(!n)flag=false; int tot=0; if(flag){ int len=strlen(s); int tmp; for(int i=0;i<len;i+=3){ tmp=(s[i]-'0') * 100+(s[i+1]-'0') * 10+s[i+2] - '0'; if(has[tmp]!='\0')ans[tot++]=has[tmp]; else { flag=false; break; } } ans[tot]=0; } printf("%s\n",flag?ans:"No Solution"); } return 0;}/*42590357035697030000100100100100110000000000010010010010012590357035697030*/
- 山东省第二届ACM大学生程序设计竞赛 Crack Mathmen 打表 模拟
- [2011山东省第二届ACM大学生程序设计竞赛]——Crack Mathmen
- 山东省第二届ACM大学生程序设计竞赛——Crack Mathmen
- SDUT 2165 Crack Mathmen(快速幂)山东省第二届ACM大学生程序设计竞赛
- [2011山东省第二届ACM大学生程序设计竞赛]——Mathmen
- 第二届山东省ACM省赛回顾 Crack Mathmen(打表)
- sdut2165 Crack Mathmen (山东省第二届ACM省赛)
- Sequence(山东省第二届ACM大学生程序设计竞赛)
- 山东省第二届ACM大学生程序设计竞赛——Identifiers
- 山东省第二届ACM大学生程序设计竞赛:Identifiers
- 山东省第二届ACM大学生程序设计竞赛:Binomial Coeffcients
- SDUT 2163 Identifiers 山东省第二届ACM大学生程序设计竞赛
- 山东省第二届ACM大学生程序设计竞赛 Identifiers
- 山东省第二届ACM大学生程序设计竞赛 Sequence
- 山东省第七届ACM大学生程序设计竞赛
- 第四届 山东省ACM大学生程序设计竞赛
- 第七届 山东省ACM大学生程序设计竞赛
- 第二届山东ACM省赛 Crack Mathmen
- Android学习记录(十) 弹框阻塞处理
- C经典 定义一维数组与二维数组
- Android(1) elipse离线安装adt后,没有图编显示
- Java连接mysql中遇到的一些问题及解决方法
- 点击删除弹出确认框,’是‘异步提交,‘否’不删除,并弹出不提交原因
- 山东省第二届ACM大学生程序设计竞赛 Crack Mathmen 打表 模拟
- css3滤镜-色彩(Chroma)滤镜
- JAVA中引用本身占用内存空间的问题
- HDU5120 (容斥原理)
- N
- android 上下滑动重影
- 【leetcode】102. Binary Tree Level Order Traversal
- URAL 1091 Tmutarakan Exams (DP或容斥)
- O