From 19922acd3279ef3446bf0d00b9ba80cd8485d612 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 1 Nov 2020 15:54:30 +0800 Subject: [PATCH] =?UTF-8?q?P1079=20Vigen=C3=A8re=20=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R41008851 --- problem/P1079/P1079.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 problem/P1079/P1079.cpp diff --git a/problem/P1079/P1079.cpp b/problem/P1079/P1079.cpp new file mode 100644 index 00000000..20f3ad19 --- /dev/null +++ b/problem/P1079/P1079.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int main() { + string k, c; + int t = 0; + cin >> k >> c; + for (int i = 0; i < c.size(); i++) { + t = (k[i % k.size()] & 31) - 1; + if((c[i] & 31) - t > 0) { + c[i] = c[i] - t; + } + else { + c[i] = c[i] - t + 26; + } + } + cout << c << endl; + return 0; +}