fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <map>
  4. #include <set>
  5. #include <cmath>
  6. #include <vector>
  7. #include <climits>
  8. #include <string>
  9. #include <algorithm>
  10. #include <sstream>
  11. using namespace std;
  12.  
  13. vector<string> split(string haystack, string needle) {
  14. vector<string> result;
  15. int startPos = 0;
  16. int foundPos = haystack.find(needle, startPos);
  17. while (foundPos != string::npos) {
  18. int count = foundPos - startPos;
  19. string token = haystack.substr(startPos, count);
  20. if (!token.empty()) {
  21. result.push_back(token);
  22. }
  23. startPos = foundPos + needle.length();
  24. foundPos = haystack.find(needle, startPos);
  25. }
  26. string token = haystack.substr(startPos, haystack.length() - startPos);
  27. if (!token.empty()) {
  28. result.push_back(token);
  29. }
  30. return result;
  31. }
  32.  
  33. string nameConvert(const string& name) {
  34. const string DELIMITER = " ";
  35. stringstream builder;
  36. auto parts = split(name, DELIMITER);
  37. for (auto part : parts) {
  38. part[0] = toupper(part[0]);
  39. transform(part.begin() + 1, part.end(), part.begin() + 1, ::tolower);
  40. builder << part << DELIMITER;
  41. }
  42. return builder.str();
  43. }
  44.  
  45. string dateConvert(const string& date) {
  46. const string DELIMITER = "/";
  47. stringstream builder;
  48. auto parts = split(date, DELIMITER);
  49. builder << setw(2) << setfill('0') << parts[0] << DELIMITER;
  50. builder << setw(2) << setfill('0') << parts[1] << DELIMITER;
  51. builder << parts[2];
  52. return builder.str();
  53. }
  54.  
  55.  
  56. int main() {
  57. ios_base::sync_with_stdio(false);
  58. cin.tie(NULL);
  59.  
  60. string s;cin >> s;
  61. long long result = 0;
  62. for (int i = 0;i < s.size();i++) {
  63. result = result * 10 % 4 + (s[i] - '0') % 4;
  64. result %= 4;
  65. }
  66. if (result == 0) {
  67. cout << "6";
  68. }
  69. if (result == 1) {
  70. cout << "8";
  71. }
  72. if (result == 2) {
  73. cout << "4";
  74. }
  75. if (result == 3) {
  76. cout << "2";
  77. }
  78. return 0;
  79. }
  80.  
  81.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
6