Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <array>
- #include <cmath>
- #include <iostream>
- #include <string>
- #include <tuple>
- constexpr double PI = 3.14159265358979323846;
- int main() {
- std::array<std::pair<double, double>, 'Z' - 'A' + 1> char_coords{};
- double disk_rad = 0.;
- std::cin >> disk_rad;
- for (unsigned i = 0; i < 26; ++i) {
- char letter;
- double angle = 0.;
- std::cin >> letter >> angle;
- angle *= PI / 180.;
- char_coords[letter - 'A'] = {std::cos(angle) * disk_rad, std::sin(angle) * disk_rad};
- }
- std::string message;
- std::cin >> std::ws;
- std::getline(std::cin, message);
- double length = 0.;
- std::pair<double, double> last_coords = {0., 0.};
- for (char c : message) {
- c = std::toupper(c);
- if ('A' <= c && c <= 'Z') {
- auto coords = char_coords[c - 'A'];
- length +=
- std::hypot(coords.first - last_coords.first, coords.second - last_coords.second);
- last_coords = coords;
- }
- }
- std::cout << std::ceil(length);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement