Skip to content

Commit

Permalink
Add 04287.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Feb 17, 2024
1 parent 332f527 commit 8dddf90
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 04xxx/04287.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include <string>
using namespace std;

inline int c2i(char c) { return c - 'a'; }
inline char i2c(int i) { return i + 'a'; }
inline int mod(int a, int b) { return (a % b + b) % b; }

bool solve(void) {
string a; cin >> a;
if (a == "#") return false;
string b, c; cin >> b >> c;

string ans = "";
for (int i=0; i<a.length(); i++) {
int d = mod(c2i(b[i]) - c2i(a[i]), 26);
ans += i2c(mod(c2i(c[i]) + d, 26));
}
cout << a << " " << b << " " << c << " " << ans << "\n";
return true;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

while (solve());
return 0;
}

0 comments on commit 8dddf90

Please sign in to comment.