题意:有n个人买苹果,当苹果剩余偶数时买走一半,当苹果剩余奇数时,先买走一半,再用半价买走一个苹果,最终苹果恰好卖完.农民收入为多少.

析:反向模拟。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} string str[55]; int main(){
while(scanf("%d %d", &n, &m) == 2){
for(int i = 0; i < n; ++i) cin >> str[i];
LL ans = 0, x = 0;
for(int i = n-1; i >= 0; --i){
if(str[i].size() > 5){
ans += x * m + m/2;
x = x * 2 + 1;
}
else{
ans += x * m;
x *= 2;
}
}
cout << ans << endl;
}
return 0;
}

CodeForces 632C Grandma Laura and Apples (模拟)的更多相关文章

  1. Educational Codeforces Round 9 A. Grandma Laura and Apples 水题

    A. Grandma Laura and Apples 题目连接: http://www.codeforces.com/contest/632/problem/A Description Grandm ...

  2. 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 s ...

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

    题意: 外祖母要卖苹果,(有很多但不知道数量),最终所有苹果都卖光了! 有n个人买苹果,如果那个人是half,他就买所有苹果的一半,如果那个人是halfplus,则他买当前苹果数量的一半,Laura还 ...

  4. 【Henu ACM Round #12 A】 Grandma Laura and Apples

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 知道题意之后就是一个模拟的过程了. 用int now记录当前苹果的个数.bool flag记录是否有小数(即半个苹果) (这样处理为 ...

  5. [CF632A]Grandma Laura and Apples

    题目大意:有$n$个顾客买苹果,每个买一半的苹果,有时会送半个苹果.最后卖光了,问卖了多少钱 题解:倒退过来,可以把半个苹果当做一份来算,这样不会有小数 卡点:无 C++ Code: #include ...

  6. 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 ...

  7. Codeforces Gym 100269B Ballot Analyzing Device 模拟题

    Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...

  8. codeforces 723B Text Document Analysis(字符串模拟,)

    题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...

  9. Codeforces Round #304 C(Div. 2)(模拟)

    题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张 ...

随机推荐

  1. [BZOJ1179] [Apio2009]Atm(tarjan缩点 + spfa)

    传送门 题意 N个点M条边的有向图 每个点有点权 从某一个结点出发 问能获得的最大点权和 一个点的点权最多被计算一次 N<=500000 M<=500000 思路 先tarjan缩点,然后 ...

  2. uva1366/LA3530

    简单的矩阵上的dp 从左上角扫到右下角,dp[i][j][0] 代表在i,j处选A ,dp[i][j][1] 代表在i,j处选B. dp[i][j][0]=max(dp[i-1][j][1],dp[i ...

  3. 【ZJOI2018 Round2游记】

    在主场作为高三退役选手要去听一些奇怪的宣讲 看看有没有PY的机会 语文考试考到一半溜出来 ZJU先上 开始挑衅 很勇啊 THU的校友 然而这些都离我太过遥远 最后PY了一波 获得了鼓励(并不) 最后的 ...

  4. 【BZOJ4559】成绩比较(组合计数,容斥原理)

    题意: G系共有n位同学,M门必修课.这N位同学的编号为0到N-1的整数,其中B神的编号为0号.这M门必修课编号为0到M- 1的整数.一位同学在必修课上可以获得的分数是1到Ui中的一个整数.如果在每门 ...

  5. hiho一下 第四十九周 欧拉路

    http://hihocoder.com/contest/hiho49/problem/1 给定无孤立结点图G,若存在一条路,经过图中每边一次且仅一次,该条路称为欧拉路. 一个无向图存在欧拉路当且仅当 ...

  6. UEFI 下安装 ubuntu 及 win8 双系统 的一些事

    给电脑原装的win8系统装Ubuntu 出现了好多问题,重装多次,刷坏一块主板后,(都是泪啊...) 终于成功. 可能的问题 1:win8 系统下进入 blos 解决方案  1)关闭快速启动:管理员命 ...

  7. codevs——1019 集合论与图论

    1019 集合论与图论  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description 集合论与图论对于小松来说 ...

  8. Servlet CDI 例子分析

    @WebServlet("/cdiservlet") //以@WebServlet注释开头,注释指定相对于上下文根的URL模式,即在根目录下使用/cdiservlet来访问 pub ...

  9. Ubuntu 16.04 GNOME添加桌面图标/在桌面上显示图标

    GNOME默认不能在桌面上创建文件夹,但是可以通过工具设置:用gnome-tweak-tool设置Nautilus接管桌面即可. 安装: sudo apt-get install gnome-twea ...

  10. Nginx系列(五)--nginx+tomcat实现负载均衡

    Nginx占有内存少,并发能力强,其实Nginx的并发能力确实在同类型的网页伺服器中表现较好.眼下中国大陆使用Nginx站点用户有:新浪,网易,腾讯等. 本文主要是基于Nginx搭建tomcat集群. ...