HDU 5938 && 2016CCPC杭州 F: Four Operations
来源:互联网 发布:摄影后期知乎 编辑:程序博客网 时间:2024/05/29 15:11
题意:
将+-x/四个符号按顺序塞入一串字符中,让它成为一个表达式
求表达式能得到的最大值
枚举'-'的位置,'x'一定挨着'-'的后面,'/'一定挨着'x'的后面
然后'+'的位置要不在'-'的前面一个,要不在第一个数后面
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define LL long longchar str[25], ch;int main(void){LL T, i, n, a, b, c, d, e, ans, cas = 1;scanf("%lld", &T);while(T--){ans = -5252532;scanf("%s", str+1);n = strlen(str+1);for(i=2;i<=n-3;i++){c = str[i+1]-'0';d = str[i+2]-'0';sscanf(str+i+3, "%lld", &e);a = str[1]-'0';ch = str[i+1];str[i+1] = 0;sscanf(str+2, "%lld", &b);str[i+1] = ch;ans = max(ans, a+b-c*d/e);ch = str[i];str[i] = 0;sscanf(str+1, "%lld", &a);str[i] = ch;b = str[i]-'0';ans = max(ans, a+b-c*d/e);}printf("Case #%lld: %lld\n", cas++, ans);}return 0;}
阅读全文
1 0
- 2016ccpc杭州赛 hdu 5938 F.Four Operations
- HDU 5938 && 2016CCPC杭州 F: Four Operations
- HDU-5938-Four Operations(杭州CCPC F题)-水题
- CCPC杭州站 HDU5938 Four Operations 贪心 枚举
- HDU 5938 Four Operations 【贪心】(2016年中国大学生程序设计竞赛(杭州))
- HDU 5938 Four Operations(2016年中国大学生程序设计竞赛(杭州))
- (2016年中国大学生程序设计竞赛(杭州)) HDU 5938 Four Operations 思维题 + 枚举
- HDU 5938 Four Operations
- hdu 5938 Four Operations
- hdu 5938 Four Operations
- 2016CCPC杭州站 F
- 2016年中国大学生程序设计竞赛(杭州) F Four Operations(暴力枚举)
- HDU 5938 Four Operations(贪心+细节)——2016年中国大学生程序设计竞赛(杭州)
- hdu 5938 Four Operations【贪心】
- hdu 5938 Four Operations 模拟
- HDU 5938 Four Operations 贪心
- HDU 5938 Four Operations 模拟
- HDU 5938 Four Operations(思维)
- hpuoj【1294】有序数组共有元素【水题】
- Tomcat8.5.20安装
- 最小点权覆盖和最大点权独立集(定义与建模)
- MATLAB 把m文件转化为C文件
- python中的控制条件、循环和跳出
- HDU 5938 && 2016CCPC杭州 F: Four Operations
- zcmu-1199
- Python的模块导入、包导入
- 各种排序及内省排序
- python中的列表、元祖、字典、集合
- hdu3333(线段树离散化离线处理)
- Judge (快速幂+同余)
- 什么是to B 业务
- 【Spring】Spring创建对象的各种方法