CF632A Grandma Laura and Apples

#include<bits/stdc++.h>
using namespace std;
long long n,p,ans=0,total=0,apple=0;
int main()
{
    string a[100000];
    cin>>n>>p;
    p=p>>1;
    for(int i=1;i<=n;i++)
    {
    cin>>a[i];
}
for(int i=n;i>=1;i--)
{
    total=total*2;
    if(a[i]=="halfplus")
        total++;
    apple+=total;
    }
    cout<<apple*p;
    return 0;
}

原文地址:https://www.cnblogs.com/dwj030917/p/10427151.html

时间: 2024-10-13 20:08:45

CF632A Grandma Laura and Apples的相关文章

codeforces 632A A. Grandma Laura and Apples

A. Grandma Laura and Apples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma

[2016-03-26][codeforces][632][A][Grandma Laura and Apples]

时间:2016-03-25 23:50:29 星期五 题目编号:[2016-03-26][codeforces][632][A][Grandma Laura and Apples] 题目大意:有n的客人,每个客人都来买一半的苹果,如果苹果为奇数,就把多出来的半个苹果送给客人,已知买个客人是否收到更多苹果,问总共应该收到多少元 分析: 最后剩下一个苹果的时候,客人只买半个苹果,送半个苹果,所以最后一个一定是plus, 直接计算所有苹果的数目,和赠送的苹果数目,求最后总值 #include <cst

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

题意: 外祖母要卖苹果,(有很多但不知道数量),最终所有苹果都卖光了! 有n个人买苹果,如果那个人是half,他就买所有苹果的一半,如果那个人是halfplus,则他买当前苹果数量的一半,Laura还会送半个苹果!问最多能赚多少钱? 思路: 会后一个人一定是halfplus,否则苹果卖不完,所以最后一个人买的时候已经只剩一个.然后从后往前推. 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #

CodeForces 632C Grandma Laura and Apples (模拟)

题意:有n个人买苹果,当苹果剩余偶数时买走一半,当苹果剩余奇数时,先买走一半,再用半价买走一个苹果,最终苹果恰好卖完.农民收入为多少. 析:反向模拟. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include &l

Pick apples 第三届acm省赛

Description Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she has never seen so many apples before. Each ki

HDU 5303 Delicious Apples(贪心 + 背包 2015多校啊)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5303 Problem Description There are n apple trees planted along a cyclic road, which is L metres long. Your storehouse is built at position 0 on that cyclic road. The ith tree is planted at position xi,

Codeforces Round #257 (Div. 2) E题:Jzzhu and Apples 模拟

E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to

CodeForces 23C Oranges and Apples 抽屉原理

题目链接:点击打开链接 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10000000 #define l

Codeforces Round #325 (Div. 2) E. Alice, Bob, Oranges and Apples

E. Alice, Bob, Oranges and Apples Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining frui