193030

2019 Olympiada 01. Word

Feb 25th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include <sstream>
  7.  
  8. using namespace std;
  9. int inputStringLength = 0;
  10. int digitSum;
  11. char tempString ;
  12. void stringChars(string inputString) {
  13.     int digit;
  14.     inputStringLength=inputString.length();
  15.     for(int i =0; i <=inputStringLength-1; i++)
  16.     {
  17.         tempString = inputString.at(i);
  18.  
  19.         digit = int(tempString);
  20.         digit -=96;
  21.         if(digit>=10)
  22.         {
  23.             int firstDigit = digit/10;
  24.             int secondDigit = digit %10;
  25.             int sumOfDigits = firstDigit + secondDigit;
  26.             digit = sumOfDigits;
  27.         }
  28.         digitSum =digitSum + (digit* pow(2, i));
  29.         digit =0;
  30.     }
  31. }
  32. int main()
  33. {
  34.   string input;
  35.   cin >> input;
  36.   stringChars(input);
  37.   if(digitSum % 2 == 0 )
  38.   cout << "yes " << digitSum;
  39.   else
  40.     cout << "No";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment