10 加密與解密

2021-10-14 18:25:28 字數 870 閱讀 6083

【問題描述】

乙個長度為n(1=a). 按遞減順序迭代n的所有因子,也就是從n到1

b). 對於每個因子d,反轉字串s的前d個字元s[0,…,d-1],從而形成新的s

給定乙個已加密的字串t(密文),你的任務是找出原始字串s(原文),輸入保證字串s是存在且唯一的。

【輸入形式】

輸入為一行乙個字串t,表示密在這裡插入**片文

【輸出形式】

輸出原文本串s

【樣例輸入】

owrldolleh

【樣例輸出】

helloworld

【樣例說明】

原文s 「helloworld」

長度為10,其因子依次為10,5,2,1

第一次變換反序前10個字元:「dlrowolleh」

第二次變換反序前5個字元:「worldolleh」

第三次變換反序前2個字元:「owrldolleh」

第四次變換反序前1個字元:「owrldolleh」

密文為"owrldolleh"

注意,最後的反轉操作不改變字串,因為d=1。

#include

#include

#include

#include

#include

using

namespace std;

intmain()

}for

(int div : divisor)

//這種寫法可以遍歷容器vector內的元素

cout << cipher << endl;

system

("pause");

return0;

}

實驗七 10 加密與解密

問題描述 乙個長度為n 1 輸入形式 輸入為一行乙個字串t,表示密文 輸出形式 輸出原文本串s 樣例輸入 owrldolleh 樣例輸出 helloworld 樣例說明 原文s helloworld 長度為10,其因子依次為10,5,2,1 第一次變換反序前10個字元 dlrowolleh 第二次變...

加密與解密

using system using system.text using system.security using system.security.cryptography using system.io function 的摘要說明 public class function dec 加密過程 ...

加密與解密

using system using system.collections.generic using system.text using system.security.cryptography using system.io 加密字元 加密字串 加密金鑰 返回加密 public class de...