Advertisement
dcndrd

10038

May 20th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<iostream>
  2. #include<sstream>
  3. #include<string>
  4. #include<vector>
  5. #include<cmath>
  6. #include<set>
  7.  
  8. using namespace std;
  9.  
  10. int main(){
  11.     string s;
  12.    
  13.     while(getline(cin, s)){
  14.         set<int> ss;
  15.         vector<int> n;
  16.         stringstream stream(s);
  17.         int t;
  18.         while(stream>>t) n.push_back(t);
  19.        
  20.    
  21.         for(int i=0; i<n.size(); i++)
  22.             if(i+1<n.size()) ss.insert(abs(n[i]-n[i+1]));
  23.        
  24.         set<int>::iterator it; 
  25.         bool b = true;
  26.         int i=1;
  27.         for(it=ss.begin(); it!=ss.end(); it++){
  28.             if(*it!=i){
  29.                 b=false;
  30.                 break;
  31.             }
  32.             i++;
  33.         }
  34.        
  35.         if(b) cout<<"Jolly"<<endl;
  36.         else cout<<"Not jolly"<<endl;
  37.     }
  38.  
  39.  
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement