Codeforces 351B Jeff and Furik

Source: Internet
Author: User

Test instructions: For a sequence, two people take turns to play the game, the first person to play first, it will exchange options adjacent and exchange, the second after playing, he has 0 each. 5 of the opportunity to add one or more in reverse order, the first person always want to play the least number of steps, then the number of steps expected.

Problem-solving idea: It turned out to be a math problem crying.

Problem Solving Code:

1 //File name:351b.cpp2 //Author:darkdream3 //Created time:2015 March 25 Wednesday 10:34 48 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long - #defineMAXN 3005 - using namespacestd; - intA[MAXN]; - intTREE[MAXN]; in intLowbit (intx) - { to    returnX &-x; + } - intN; the voidUpdateintx) * { $      while(x <=N)Panax Notoginseng     { -TREE[X] + =1; theX + =lowbit (x); +     } A } the intGetsum (intx) + { -   intAns =0 ;  $    while(x >=1 ) $   { -Ans + =Tree[x]; -X-=lowbit (x); the   } -   returnans;Wuyi } the intMain () { -scanf"%d",&n); Wu     intNX =0 ;  -      for(intI=1; I <= N;i + +) About     { $scanf"%d",&a[i]); -NX + = I-getsum (A[i])-1; -       //printf ("%d\n", NX); - Update (a[i]); A     } +     if(NX%2==1 ) theprintf"%LF",2*nx-1.0); -     Elseprintf"%LF",2.0*NX); $           the return 0; the}
View Code

Codeforces 351B Jeff and Furik

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.