https://i2.wp.com/eblogarithm.com/wp-content/uploads/2017/07/Codeforces-Round-410-Div-2-problem-C-Mike-and-gcd-problem-Solution-In-CC1.png?fit=640%2C360

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 38 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: