Educational Codeforces Round 9--A-GRANDMA Laura and Apples

Source: Internet
Author: User

Test instructions

grandma wants to sell apples, (there are many but no numbers) and eventually all the apples are sold out!
There are n people buy apples, if that person is half, he buys half of all apples, if that person is halfplus, then he buys half of current Apple quantity, Laura also will send half an apple! How much money can you make? Ideas:after the meeting a person must be halfplus, otherwise the Apple sells not to finish, so the last person buys the time already only then one. Then push forward from behind.
1#include <cstdio>2#include <cstring>3#include <algorithm>4#include <iostream>5#include <cstdlib>6#include <string>7#include <cmath>8#include <vector>9 using namespacestd;Ten Const intmaxn=1e5+7; One Const Doubleeps=1e-8; A Const DoublePi=acos (-1); - #definell Long Long - intMain () the { - ll N,m; -     Charstr[ -][ -]; -      while(~SCANF ("%i64d%i64d",&n,&m)) +     { -ll num=0; +ll ans=0; A          for(intI=0; i<n;i++) atscanf"%s", Str[i]); -          for(inti=n-1; i>=0; i--) -         { -             if(!STRCMP (Str[i),"Halfplus")) -             { -Num= (num+0.5)*2; inans+=num/2.0*m; -             } to             Else +             { -num=num*2; theans+=num/2*m; *             } $         }Panax Notoginsengprintf"%i64d\n", ans); -     } the     return 0; +}
View Code

Educational Codeforces Round 9--A-GRANDMA Laura and Apples

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.