題目鏈接: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,' 主站蜘蛛池模板: 久久精品一区二区免费看 | 免费观看无遮挡www的视频 | video18娇小粉嫩极品hd | 亚洲精品老司机综合影院 | 亚洲国产片| 日韩欧美一区二区三区不卡在线 | 欧美一级别 | ady久久 | 亚洲欧美中文字幕高清在线一 | 亚洲色图网站 | 成人欧美一级毛片免费观看 | 毛片毛片 | 91刘亦菲精品福利在线 | 国产精品jizz在线观看免费 | 色视频在线播放 | 亚洲线精品一区二区三区 | 国产亚洲精品精品国产亚洲综合 | 明星三级国产免费播放 | 久久久久亚洲日日精品 | 国产精品免费久久久久影院小说 | 中文字幕亚洲综合久久202 | 亚洲毛片视频 | 久久本网站受美利坚法律保护 | 日本免费一二区视频 | www.日本在线播放 | www.日本xxxx| 亚洲激情专区 | 亚洲精品国产一区二区在线 | 亚洲三级黄色片 | 亚洲人成在线播放网站 | 国产a不卡片精品免费观看 国产a国产片色老头 | 国产精品成人不卡在线观看 | 久草在线免费色站 | 日本日韩欧美 | 五月婷婷视频 | 日韩亚洲国产综合久久久 | 亚洲综合一区二区精品久久 | 欧美 亚洲 中文字幕 | 国产精品区一区二区三 | 久久xxx| 91中文字幕yellow字幕网 |