UVA-1594-Ducci序列-水题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39651984/article/details/79038423

水题直接写就行

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef stringstream strstm;
#define PI acos(-1.0)
#define E 2.718281829459
#define pb push_back
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define CLR(a) MST(a,0);
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)

const int maxn = 15 + 2;
int arr[maxn];

int main(int argc, char const *argv[])
{
	int k; cin >> k;
	while(k--){
		CLR(arr);
		int n; cin >> n;
		_for(i,0,n) cin >> arr[i];
		_rep(i,0,1000){
			int t = arr[0];
			_for(j,0,n){
				if(j == n-1) arr[j] = abs(arr[j] - t);
				else arr[j] = abs(arr[j] - arr[j+1]);
			}
		}
		_for(i,0,n){
			if(arr[i]){
				 cout << "LOOP" << endl;
				 goto END;
			}
		}
		cout << "ZERO" << endl;
		END:{}
	}

	return 0;
}


猜你喜欢

转载自blog.csdn.net/qq_39651984/article/details/79038423
今日推荐