CF#511-C Enlarge GCD(gcd)

Meaning of the questions: to give you a sequence, then the greatest common divisor of the whole sequence number increases after deleting a few
ideas: We first asked the gcd of the public, then we can try to make gcd increased to increase and determine whether gcd there is a number for the number of gcd
while the number of statistics, the largest is the last of the required values for public gcd. (That is, increase the upper limit to the maximum number)
in the range of 1 ~ 1e5, arr [i] is 1.5e7

Complete code:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int arr[maxn];
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int main(){
    int n;
    while(cin>>n){
        for(int i =0 ;i<n;i++){
            cin>>arr[i];
        }
        sort(arr,arr+n);
        int g = arr[0];
        for(int i = 1;i<n;i++){
            g = gcd(arr[i],g);
        }
        int ans = 0;
        int cont;
        for(int j = g;j<=arr[n-1];j++){
            cont = 0;
            for(int k = 0;k<n;k++){
                if(arr [i]% g) continue ;
                else cont ++ ; 
            } 
            Years = max (years cont); 
        } 
        Cout << n-years << endl; 

    } 
}

 

Guess you like

Origin www.cnblogs.com/Tianwell/p/11320374.html
gcd