CodeForces 632C Grandma Laura and Apples (模拟)
题意:有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 (模拟)的更多相关文章
- Educational Codeforces Round 9 A. Grandma Laura and Apples 水题
A. Grandma Laura and Apples 题目连接: http://www.codeforces.com/contest/632/problem/A Description Grandm ...
- 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 ...
- Educational Codeforces Round 9 -- A - Grandma Laura and Apples
题意: 外祖母要卖苹果,(有很多但不知道数量),最终所有苹果都卖光了! 有n个人买苹果,如果那个人是half,他就买所有苹果的一半,如果那个人是halfplus,则他买当前苹果数量的一半,Laura还 ...
- 【Henu ACM Round #12 A】 Grandma Laura and Apples
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 知道题意之后就是一个模拟的过程了. 用int now记录当前苹果的个数.bool flag记录是否有小数(即半个苹果) (这样处理为 ...
- [CF632A]Grandma Laura and Apples
题目大意:有$n$个顾客买苹果,每个买一半的苹果,有时会送半个苹果.最后卖光了,问卖了多少钱 题解:倒退过来,可以把半个苹果当做一份来算,这样不会有小数 卡点:无 C++ Code: #include ...
- 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 ...
- Codeforces Gym 100269B Ballot Analyzing Device 模拟题
Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...
- codeforces 723B Text Document Analysis(字符串模拟,)
题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...
- Codeforces Round #304 C(Div. 2)(模拟)
题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张 ...
随机推荐
- LeetCode(56)Merge Intervals
题目 Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6], ...
- 找到多个与名为“Home”的控制器匹配的类型。
原因分析 其实上面已经讲的很清楚了,找到了两个同名Home控制器,需要配置命名空间来区分. 解决方法 方法一:修改RouteConfig.cs 方法二:修改RouteConfig.cs 和 Admin ...
- JavaScript编程那些事(牛客网 LeetCode)
计算给定数组 arr 中所有元素的总和 本人提供常规方法 function sum(arr) { var len = arr.length; var sum = 0; if(len == 0){ su ...
- BNUOJ 5235 Starship Troopers
Starship Troopers Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on HDU. Origi ...
- NYOJ-769乘数密码,逆元解法;
乘数密码 时间限制:1000 ms | 内存限制:65535 KB 难度:1 -> Link <- 简单代替密码的第二种,比移位密码稍微复杂点,不过鉴于NYOJ,是完全可以 ...
- android源码mm时的编译错误no ruler to make target `out/target/common/obj/JAVA_LIBRARIES/xxxx/javalib.jar', needed by `out/target/common/obj/APPS/xxxx_intermediates/classes-full-debug.jar'. Stop.
瞧见没有,就因为多了这一个反斜杠,浪费了一下午时间找问题,哭了~~~~
- linux 文件系统 磁盘分区 格式化
1.du -sh test #查看文件或者目录的大小 2.cat file | wc -l #查看文件的行数 3.ls dirname | wc -l #查看文件个数 4.stat install.l ...
- SOJ 2818_QQ音速
[题意]两只手,一次只能用一只手按一个键子(0,1,2,3),给出从i键到j键所需的消耗的体力,求依次按下一系列键子所需最小体力. [分析] 法一:开一个三维数组,分别记录移动到位置及左右手按的键子. ...
- 权限框架之Shiro详解(非原创)
文章大纲 一.权限框架介绍二.Shiro基础介绍三.Spring Boot整合Shiro代码实战四.项目源码与资料下载五.参考文章 一.权限框架介绍 1. 什么是权限管理 权限管理属于系统安全 ...
- 03-js变量强制转换
<html> <head> <title>js中的变量强转</title> <meta charset="UTF-8"/> ...