Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define optimizar ios_base::sync_with_stdio(0); cin.tie(0)
  3. #define lld long long int
  4. #define llf long double
  5. using namespace std;
  6. const int MAXN = 100002;
  7.  
  8. int c;
  9. lld res[3];
  10.  
  11. int main()
  12. {
  13. optimizar;
  14. string S;
  15. while(cin >> S) {
  16. c = res[1] = res[2] = 0;
  17. res[0] = 1;
  18. lld r = 0;
  19. for(int i = 0; i < S.size(); i++) {
  20. if(S[i] < '0' || S[i] > '9') {
  21. c = res[1] = res[2] = 0;
  22. res[0] = 1;
  23. continue;
  24. }
  25. c += S[i] - '0';
  26. c %= 3;
  27. r += res[c];
  28. res[c]++;
  29. }
  30. cout << r << "\n";
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement