diff options
| -rw-r--r-- | 10038/jolly.cpp | 26 | ||||
| -rw-r--r-- | 10038/jolly.in | 12 |
2 files changed, 38 insertions, 0 deletions
diff --git a/10038/jolly.cpp b/10038/jolly.cpp new file mode 100644 index 0000000..53625e1 --- /dev/null +++ b/10038/jolly.cpp @@ -0,0 +1,26 @@ +#include <iostream> +#include <math.h> +using namespace std; + +int main(){ + int n; + while(cin>>n){ + int nums[3000], diffs[2999]={0}, i; + bool jolly=true; + for(i=0; i<n; i++) + cin>>nums[i]; + for(i=1; i<n; i++) + diffs[abs(nums[i]-nums[i-1])]=1; + for(i=1; i<n; i++){ + if(diffs[i]==0){ + jolly=false; + break; + } + } + if(jolly) + cout<<"Jolly\n"; + else + cout<<"Not jolly\n"; + } + return 0; +} diff --git a/10038/jolly.in b/10038/jolly.in new file mode 100644 index 0000000..85b39f4 --- /dev/null +++ b/10038/jolly.in @@ -0,0 +1,12 @@ +1 2000 +5 1 4 2 -1 6 +2 1999 1998 +4 1 4 2 3 +4 1 3 2 -2 +4 1 4 3 5 +4 1 2 5 7 +3 4 1 3 +4 1 4 2 3 +4 1 2 3 6 +2 1 3 +1 1
\ No newline at end of file |
