SHARE
TWEET

Untitled

a guest Oct 21st, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <array>
  2. #include <cmath>
  3. #include <iostream>
  4. #include <string>
  5. #include <tuple>
  6.  
  7. constexpr double PI = 3.14159265358979323846;
  8.  
  9. int main() {
  10.     std::array<std::pair<double, double>, 'Z' - 'A' + 1> char_coords{};
  11.     double disk_rad = 0.;
  12.     std::cin >> disk_rad;
  13.     for (unsigned i = 0; i < 26; ++i) {
  14.         char letter;
  15.         double angle = 0.;
  16.         std::cin >> letter >> angle;
  17.         angle *= PI / 180.;
  18.         char_coords[letter - 'A'] = {std::cos(angle) * disk_rad, std::sin(angle) * disk_rad};
  19.     }
  20.  
  21.     std::string message;
  22.     std::cin >> std::ws;
  23.     std::getline(std::cin, message);
  24.     double length = 0.;
  25.     std::pair<double, double> last_coords = {0., 0.};
  26.     for (char c : message) {
  27.         c = std::toupper(c);
  28.         if ('A' <= c && c <= 'Z') {
  29.             auto coords = char_coords[c - 'A'];
  30.             length +=
  31.                 std::hypot(coords.first - last_coords.first, coords.second - last_coords.second);
  32.             last_coords = coords;
  33.         }
  34.     }
  35.  
  36.     std::cout << std::ceil(length);
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top