題目鏈接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2165
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?
3 2 590357035697030 0 001001001001001 1000000000 001001001001001
World No Solution No Solution 第1行3,代表3組數據,然后每組輸入兩行 第1行是 n 第2行是要破譯的密碼; 把密碼分成每3個數字1組,去破譯 例如第1組樣例 590357035697030 把它每3個拆成1組,每組翻譯成1個字符,第1行輸入的 n=2,代表該字符asc碼的幾次方 例如 590 = 87^2%997 , 'W的'asc碼就是 87,, 所以第1個字母是 W,順次類推輸出了 World; 可以看出只要我們知道了asc碼,我們就可以求出 對應的字符,很容易想到打表,由于題目說翻譯后的密碼只包括大小寫字母和數字,數組不用開很大就可以貯存; 而 對求冪取模,,直接套用快速冪模板就好了。 No Solution的情況: 1:沒有對應的字符 2:對應的字符多于1個#include <stdio.h> #include <cmath> #include <cstring> #include <stdlib.h> typedef long long ll; const int maxn=1000000+10; char str[maxn]; char test[maxn/3][5]; char ar[1010]; int signaa; ll pow_mod(ll x,ll n, ll mod) //快速冪模板 { ll res=1; x=x%mod; while(n>0) { if(n%2) { res=res*x%mod; } x=x*x%mod; n/=2; } return res; } int main() { int n; scanf("%d",&n); int cas=0; while(n--) { signaa=0; memset(ar,' 主站蜘蛛池模板: 国产精品久久久久一区二区 | 日韩精品在线免费观看 | 在线免费福利 | 福利视频免费观看 | 免费一区 | 99久久免费国产 | 久久精品视频一区二区 | 精品一区二区三区免费 | 精品九九 | 国产成人精品综合 | 无码精品一区二区三区免费视频 | 国产伦精品一区二区三区高清版 | 91久久久久久久久久久久久 | 在线国产一区二区 | 欧美一区二区三区国产 | 日韩精品久久久久 | 爱情岛免费永久网站 | 精品国产髙清在线看国产毛片 | jizzz亚洲| 国产精品99久久久久久似苏梦涵 | 亚洲欧美精品一区 | 国产欧美日韩在线观看 | 欧美成人a| 插美女网站 | 99福利视频 | 99国产一区 | 亚洲日本va中文字幕久久 | 日本a在线 | 在线免费黄色 | 成人av一区二区三区 | 一区二视频 | 在线一区二区三区 | 久久999| 精品国产一区二区三区久久久 | 国产一区高清 | 欧美视频一区二区三区 | 日本欧美国产在线观看 | 狼人综合网 | 成年人免费视频观看 | 午夜午夜精品一区二区三区文 | 91亚洲成a人片在线观看www |