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;
    }
    
    
    • 0
      @ 2026-6-3 19:37:01
      #include<bits/stdc++.h>
      using namespace std;
      int n;
      int main()
      {
      	cin>>n;
      	for(int d=1;d<=n;d++)
      	{
      		int x;
      		int a[100005];
      		cin>>x;
      		for(int i=1;i<=x;i++)
      		{
      			cin>>a[i];
      		}
      		bool s=false;
      		for(int i=1;i<=x;i++)
      		{
      			bool f=true;
      			for(int j=1;j<=x;j++)
      			{
      				if(a[i]%a[j]!=0)
      				{
      					f=false;
      				}
      			}
      			if(f)
      			{
      				s=true;
      				break;
      			}
      		}
      		if(s)
      		{
      			cout<<"Yes"<<endl;
      		}
      		else{
      			cout<<"No"<<endl;
      		}
      	}
      	return 0;
      }
      
      • 1

      Information

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