Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- string s;
- getline(cin, s);
- vector <int> a(0);
- a.push_back(-1);
- int position = 0;
- if (s.find('.') == -1){
- cout << "NO";
- return 0;
- }
- for (auto c : s){
- if ((c < '0' || c > '9') && c!='.'){
- cout << "NO";
- return 0;
- }
- if (c == '.'){
- a.push_back(position);
- }
- position++;
- }
- a.push_back(s.size());
- if (a.size() != 5){
- cout << "NO";
- return 0;
- }
- for (int i = 1; i < a.size(); i++){
- if ((a[i] - a[i - 1] == 1) || (a[i] - a[i - 1] >= 5)){
- cout << "NO";
- return 0;
- }
- else if ((a[i] - a[i - 1] - 1) == 3){
- if (s[a[i - 1] + 1]>'2'){
- cout << "NO";
- return 0;
- }
- if ((s[a[i - 1] + 1] == '2') && (s[a[i - 1] + 2] > '5')){
- cout << "NO";
- return 0;
- }
- if ((s[a[i - 1] + 1] == '2') && (s[a[i - 1] + 2] == '5') && (s[a[i - 1] + 3] > '5')){
- cout << "NO";
- return 0;
- }
- }
- }
- cout << "YES";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement