UVA1594

#include"iostream"
#include"algorithm"
#include"vector"
#include"map"
#include"string"
#include"deque"
#include"queue"
#include"stack"
#include"cstdio"
#include"cmath"
using namespace std;
int main()
{
	//freopen("a.txt","r",stdin);
	int t;
	cin>>t;
	while(t--)
	{
		int f=0;
		int n;
		cin>>n;
		vectora;
		while(n--)
		{
			int sb;
			cin>>sb;
			a.push_back (sb);
		}
		int k=1000;
		while(k--)
		{
			int start=a.front();
		for(auto p=a.begin();p!=a.end();p++)
		{
			if(p!=a.end()-1)
			{
			*p=abs(*p-*(p+1));
			//cout<<*p<<" ";
			}
			else
			{
			*p=abs(*p-start);
			//cout<<*p<<" ";
			}
		}
		int num=0;
		for(auto q=a.begin();q!=a.end();q++)
		{
			if(*q==0)
				num++;
		}
		if(num==a.size())
		{
			f=1;
			break;
		}
		}
		//cout<

你可能感兴趣的:(UVA)