标签:href ble force 学习 display can clu return blog
http://www.cnblogs.com/BBBob/p/6746721.html
1 #include<iostream> 2 #include<cstdio> 3 #include<string> 4 #include<cstring> 5 #include<algorithm> 6 #include<cmath> 7 8 using namespace std; 9 const int maxn=1e5+10; 10 int a[maxn]; 11 12 int gcd(int a,int b) 13 { 14 if(b==0) 15 { 16 return a; 17 } 18 return gcd(b,a%b); 19 } 20 int main() 21 { 22 int n; 23 scanf("%d",&n); 24 for(int i=0;i<n;i++) 25 { 26 scanf("%d",&a[i]); 27 } 28 int g=a[0]; 29 for(int i=1;i<n;i++) 30 { 31 g=gcd(g,a[i]); 32 } 33 if(g!=1) 34 { 35 printf("YES\n"); 36 printf("0"); 37 return 0; 38 } 39 int ans=0; 40 for(int i=0;i<n;i++) 41 { 42 if(a[i]%2==1) 43 { 44 if(a[i+1]%2==1) 45 { 46 ans++; 47 } 48 else 49 { 50 ans+=2; 51 } 52 i++; 53 } 54 } 55 printf("YES\n"); 56 printf("%d\n",ans); 57 return 0; 58 }
【算法系列学习】codeforces C. Mike and gcd problem
标签:href ble force 学习 display can clu return blog
原文地址:http://www.cnblogs.com/itcsl/p/6758803.html