#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;
const int maxn = 1010;
vector<int> a;
int t, n;
bool is_zero()
{
int p, q = 0;
for(int i = 0; i < maxn; i++)
{
q = 0;
p = a[0];
for(int j = 0; j < n-1; j++)
{
a[j] = abs(a[j] - a[j+1]);
if(!a[j])
q++;
}
a[n - 1] = abs(a[n-1] - p);
if(!a[n-1])
q++;
if(q == n)
return true;
}
return false;
}
int main()
{
int x;
cin >> t;
while(t--){
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> x;
a.push_back(x);
}
if(is_zero())
cout << "ZERO" << endl;
else
cout << "LOOP" << endl;
a.clear();
}
return 0;
}
uva1594 - Ducci Sequence
最新推荐文章于 2022-08-16 16:25:47 发布