國家集訓隊2011 悄悄話

2022-03-27 02:32:36 字數 2775 閱讀 6403

在這個有話不直說的年代,密碼學越來越被廣泛接受。

我們引用經典的「凱撒密碼」。

在英文中,凱撒加密只對26個字母生效(分大小寫)

我們按照』a』到』z』來排字母。

凱撒加密的原理就是把原文的每乙個字母都按順序往後移k位。這個k將被作為金鑰。(』a』往後移變成』b』,』z』往後移會變成』a』)

(0 ≤ k ≤ 25)

現在給出一系列用凱撒加密的英文句子,請你編寫程式逐句翻譯。

也就是說,請你確定乙個金鑰,使得解碼以後的文字最符合英文的規則與規範。

資料保證存在唯一的解碼方案,使得明碼是完全可以分辨的英文句子。

輸入一定包括10行

每一行都是用同一金鑰加密的英文

輸出10行,為解密結果。不允許格式上有任何不同。

welcome to the test. this is the 1st sample test case.

vdkbnld sn sgd sdrs. sghr hr sgd 2mc rzlokd sdrs bzrd.

welcome to the test. this is the 3rd sample test case.

nvctfdv kf kyv kvjk. kyzj zj kyv 4ky jrdgcv kvjk trjv.

govmywo dy dro docd. drsc sc dro 5dr ckwzvo docd mkco.

nvctfdv kf kyv kvjk. kyzj zj kyv 6ky jrdgcv kvjk trjv.

jrypbzr gb gur grfg. guvf vf gur 7gu fnzcyr grfg pnfr.

ucjamkc rm rfc rcqr. rfgq gq rfc 8rf qyknjc rcqr ayqc.

ckriusk zu znk zkyz. znoy oy znk 9zn ygsvrk zkyz igyk.

xfmdpnf up uif uftu. uijt jt uif mbtu tbnqmf uftu dbtf.

welcome to the test. this is the 1st sample test case.

welcome to the test. this is the 2nd sample test case.

welcome to the test. this is the 3rd sample test case.

welcome to the test. this is the 4th sample test case.

welcome to the test. this is the 5th sample test case.

welcome to the test. this is the 6th sample test case.

welcome to the test. this is the 7th sample test case.

welcome to the test. this is the 8th sample test case.

welcome to the test. this is the 9th sample test case.

welcome to the test. this is the last sample test case.

毒瘤= =

我會說我對著資料擴充套件我的詞典嗎qwq

首先,我們肯定要得到這26個字串,然後,對每個字串進行估值,判斷每個串是正常句子的可能性,找到最大的作為答案

所以問題就在於如何搞這個可能性,我們需要乙個估值函式,利用字母出現的頻率與是否出現常見單詞(這tm就是那個詞典啊qwq)來估值,得到每個串的估計值並選擇最大的字串

真是毒瘤啊qwq

1 #include 2 #include 3 #include 

4 #include 5 #include

6using

namespace

std;

7string dic[34]=;

8set

s;9int typ[10005],val[26

],len;

10string txt[26

];11

char common[26]=,rear[26]=;

12 inline void

pre()

16 inline bool low(char x)

17 inline void turn(string &x)

23else

if(!low(x[i]))typ[i]=2;24

}25}26 inline void trans(string x,string &y,int

w)32

//cout<33

}34 inline int cal(string

x)42

if(x[i]=='

\''&&i+1

1]=='

s'||x[i+1]=='

m'))ret+=4;43

}44int i(0

),j;

45while(i

53//

cout<54

return

ret;55}

56 inline void print(string

x)61 putchar('\n'

);62}63

intmain()

71print(txt[ans]);72}

73 }

view code

happiness 國家集訓隊2011 吳確

2011中國國家集訓隊命題答辯 高一一班的座位表是個n m的矩陣,經過乙個學期的相處,每個同學和前後左右相鄰的同學互相成為了好朋友。這學期要分文理科了,每個同學對於選擇文科與理科有著自己的喜悅值,而一對好朋友如果能同時選文科或者理科,那麼他們又將收穫一些喜悅值。作為計算機競賽教練的scp大老闆,想知...

國家集訓隊 旅遊

題目背景 ray 樂忠於旅遊,這次他來到了 t 城。t 城是乙個水上城市,一共有 nn 個景點,有些景點之間會用一座橋連線。為了方便遊客到達每個景點但又為了節約成本,t 城的任意兩個景點之間有且只有一條路徑。換句話說,t 城中只有 n 1n 1 座橋。ray 發現,有些橋上可以看到美麗的景色,讓人心...

國家集訓隊 Tree I

題目 給你乙個無向帶權連通圖,每條邊是黑色或白色。讓你求一棵最小權的恰好有nee dneed need 條白色邊的生成樹。題目保證有解。思路 凸優化裸題,要注意的就是,優先選白色 優先選黑色也行 主要是同一斜率可能會切到很多點,那麼就要有乙個標準,要麼選最小點,要麼選最大。另外求出來的點不一定是ne...