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