【算法系列学习】codeforces C. Mike and gcd problem

C. Mike and gcd problem

http://www.cnblogs.com/BBBob/p/6746721.html

 #include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath> using namespace std;
const int maxn=1e5+;
int a[maxn]; int gcd(int a,int b)
{
if(b==)
{
return a;
}
return gcd(b,a%b);
}
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
int g=a[];
for(int i=;i<n;i++)
{
g=gcd(g,a[i]);
}
if(g!=)
{
printf("YES\n");
printf("");
return ;
}
int ans=;
for(int i=;i<n;i++)
{
if(a[i]%==)
{
if(a[i+]%==)
{
ans++;
}
else
{
ans+=;
}
i++;
}
}
printf("YES\n");
printf("%d\n",ans);
return ;
}
上一篇:切换到ZSH以后遇到的坑


下一篇:SQLite开发工具