Advertisement
MathQ_

Untitled

Oct 18th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <vector>
  7. #include <stack>
  8. #include <deque>
  9. #include <queue>
  10. #include <set>
  11. #include <map>
  12. #include <stack>
  13. #include <string>
  14. #include <random>
  15. #include <numeric>
  16. #include <unordered_set>
  17.  
  18. typedef long long ll;
  19. typedef long double lb;
  20.  
  21. #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  22. #define file_in freopen("input.txt", "r", stdin);
  23. #define file_in_out freopen("inverse.in", "r", stdin); freopen("inverse.out", "w", stdout);
  24. #define mp make_pair
  25. #define all(x) (x).begin(), (x).end()
  26. #define fi first
  27. #define se second
  28.  
  29. using namespace std;
  30.  
  31. template<typename T>
  32. istream& operator>>(istream &in, vector<T> &v) {
  33. for (auto &it : v) {
  34. in >> it;
  35. }
  36. return in;
  37. }
  38.  
  39. template<typename T>
  40. ostream& operator<<(ostream &out, vector<T> &v) {
  41. if (!v.empty()) {
  42. out << v.front();
  43. for (int i = 1; i < v.size(); ++i) {
  44. out << " " << v[i];
  45. }
  46. }
  47. return out;
  48. }
  49.  
  50. int main()
  51. {
  52. fast
  53. // file_in
  54. // file_in_out
  55.  
  56. string s;
  57. cin >> s;
  58. int ans = 0;
  59. for (int i = 0; i < s.size() / 2; ++i) {
  60. if (s[i] != '0') {
  61. ++ans;
  62. }
  63. }
  64.  
  65. if (s.size() % 2 == 0) {
  66. for (int i = s.size() / 2; i < s.size(); ++i) {
  67. if (s[i] < s[i - s.size() / 2]) {
  68. --ans;
  69. break;
  70. } else if (s[i] > s[i - s.size() / 2]) {
  71. break;
  72. }
  73. }
  74. }
  75. cout << ans;
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement