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

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#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;
}

📦 Looking for Codeforces Round 410 Div Problem Mike? Check the best deals on Amazon.

🛒 Shop Codeforces Round 410 Div Problem Mike on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#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;
}

📦 Looking for Codeforces Round 410 Div Problem Mike? Check the best deals on Amazon.

🛒 Shop Codeforces Round 410 Div Problem Mike on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

How Viral Kitchen Gadgets Is Quietly Changing the Game

📢 As an Amazon Associate, I earn from qualifying purchases.I stumbled across this while desperately trying to fix a recurring problem in my routine....

DELIVAN to Unveil Production Models at IAA Transportation 2026

The commercial vehicle sector in Europe is on the brink of an exciting transformation as DELIVAN, the dedicated European-focused van brand established by global...

The Real Truth About Viral Kitchen Gadgets Before You Buy

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Viral Kitchen Gadgets through a proper 30-day real-world test, I can tell...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!