Codeforces Round #410 (Div. 2), problem: (C) Mike and gcd problem Solution In C/C++

#include <bits/stdc++.h>

using namespace std;
int main(){
int n, num = 0, x, sum = 0;
scanf(“%d”, &n);
int g=0;
for(int i = 0; i < n; ++i){
scanf(“%d”, &x);
g=__gcd(g,x);
if(x&1){
num ++;
}else{
sum = sum + num/2 + (num%2)*2;
num = 0;
}
}

if(num) sum = sum + num/2 + (num%2)*2;
if (g>1)sum=0;
printf(“YES\n%d\n”, sum);
return 0;
}

(Visited 51 times, 1 visits today)

About the Author:

Leave A Comment