"Algorithm Series learning" Codeforces C. Mike and GCD problem

Source: Internet
Author: User
Tags gcd

C. Mike and GCD problem

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 namespacestd;9 Const intmaxn=1e5+Ten;Ten intA[MAXN]; One  A intgcdintAintb) - { -     if(b==0) the     { -         returnA; -     } -     returnGCD (b,a%b); + } - intMain () + { A     intN; atscanf"%d",&n); -      for(intI=0; i<n;i++) -     { -scanf"%d",&a[i]); -     } -     intg=a[0]; in      for(intI=1; i<n;i++) -     { tog=gcd (G,a[i]); +     } -     if(g!=1) the     { *printf"yes\n"); $printf"0");Panax Notoginseng         return 0; -     } the     intans=0; +      for(intI=0; i<n;i++) A     { the         if(a[i]%2==1) +         { -             if(a[i+1]%2==1) $             { $ans++; -             } -             Else the             { -ans+=2;Wuyi             } thei++; -         } Wu      }   -printf"yes\n"); Aboutprintf"%d\n", ans); $     return 0; -}
View Code

"Algorithm Series learning" Codeforces C. Mike and GCD problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.