結果

問題 No.18 うーさー暗号
ユーザー Vertigo
提出日時 2024-04-08 16:02:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 67,592 KB
最終ジャッジ日時 2025-02-20 23:06:51
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

string decrypt(string encrypted) {
    string decrypted = "";
    int shift = 1;
    for (int i = 0; i < encrypted.length(); i++) {
        char decryptedChar = encrypted[i] - shift;
        if (decryptedChar < 'A') {
            decryptedChar += 26;
        }
        decrypted += decryptedChar;
        shift = (i + 1) % 26 + 1;
    }
    return decrypted;
}

int main() {
    string encrypted;
    cin >> encrypted;
    string decrypted = decrypt(encrypted);
    cout << decrypted << endl;
    return 0;
}
0