2 solutions

  • 0
    @ 2026-6-3 19:48:39
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+10;
    int a[N];
    int main()
    {
    	int t;
    	cin>>t;
    	while(t--)
    	{
    		int n;
    		cin>>n;
    		int maxv=-1;
    		for(int i=1;i<=n;i++)
    		{
    			cin>>a[i];
    			maxv=max(a[i],maxv);
    		}
    		int cnt=0;
    		for(int i=1;i<=n;i++)
    		{
    			if(maxv%a[i]==0)
    			{
    				cnt++;
    			}
    		}
    		if(cnt==n)
    		{
    			cout<<"Yes"<<endl;
    		}
    		else
    		{
    			cout<<"No"<<endl;
    		}
    		
    	}
    	return 0;
    }
    
    

    Information

    ID
    2182
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    43
    Accepted
    10
    Uploaded By