【UVA - 10038】Jolly Jumpers (模擬,水題,標記)
阿新 • • 發佈:2018-12-08
題幹:
題目大意:
要任意相鄰的兩個數的絕對值在[1,n),而且這個範圍內的每個數都要出現一次。
解題報告:
直接模擬就行了、
AC程式碼:
#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair #define fi first #define se second using namespace std; const int MAX = 2e5 + 5; int n; bool bk[MAX]; int a[MAX]; int main() { while(~scanf("%d",&n)) { int flag = 1; memset(bk,0,sizeof bk); for(int i = 1; i<=n; i++) scanf("%d",a+i); for(int i = 1; i< n; i++) { bk[(int)abs(a[i]-a[i+1])]=1; // printf("%d\n",(int)abs(a[i]-a[i+1])); } for(int i = 1; i<=n-1; i++) { if(bk[i]==0) { flag = 0; } } if(flag) puts("Jolly"); else puts("Not jolly"); } return 0 ; }