Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5. int main()
  6. {
  7. string s;
  8. getline(cin, s);
  9. vector <int> a(0);
  10. a.push_back(-1);
  11. int position = 0;
  12. if (s.find('.') == -1){
  13. cout << "NO";
  14. return 0;
  15. }
  16. for (auto c : s){
  17. if ((c < '0' || c > '9') && c!='.'){
  18. cout << "NO";
  19. return 0;
  20. }
  21. if (c == '.'){
  22. a.push_back(position);
  23. }
  24. position++;
  25. }
  26. a.push_back(s.size());
  27. if (a.size() != 5){
  28. cout << "NO";
  29. return 0;
  30. }
  31. for (int i = 1; i < a.size(); i++){
  32. if ((a[i] - a[i - 1] == 1) || (a[i] - a[i - 1] >= 5)){
  33. cout << "NO";
  34. return 0;
  35. }
  36. else if ((a[i] - a[i - 1] - 1) == 3){
  37. if (s[a[i - 1] + 1]>'2'){
  38. cout << "NO";
  39. return 0;
  40. }
  41. if ((s[a[i - 1] + 1] == '2') && (s[a[i - 1] + 2] > '5')){
  42. cout << "NO";
  43. return 0;
  44. }
  45. if ((s[a[i - 1] + 1] == '2') && (s[a[i - 1] + 2] == '5') && (s[a[i - 1] + 3] > '5')){
  46. cout << "NO";
  47. return 0;
  48. }
  49. }
  50. }
  51. cout << "YES";
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement