SPOJ水题WA求助(悬1关)
查看原帖
SPOJ水题WA求助(悬1关)
1393853
I_will_AKNOI楼主2024/8/21 11:01
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
int main()
{
	stack<long long>k;
	long long t;
	cin>>t;
	while(t--)
	{
		long long n,m,g,s=0,f=0;
		cin>>n>>m>>g;
		s=g;
		m--;
		while(m--)
		{
			long long x;
			cin>>x;
			k.push(x);
			if(!f)g=__gcd(g,x);
			if(g==1)f=1;
		}
		while(!k.empty())
		{
			s+=k.top()/g;
			k.pop();
		}
		if(n%s==0)cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}
2024/8/21 11:01
加载中...