2016ccpc杭州赛 hdu 5938 F.Four Operations

Keil-C51 与 Keil -ARM 共存的方法 本篇为《嵌入式相关》系列博客的第五篇,该系列博客主要记录单片机开发及硬件设计的相关过程,方便以后查阅。 Keil-C51 与 Keil -ARM 共存的方法状况解决方案1测试解决方案2 状况 今天装完Keil-C51,然后又换装了Keil-ARM之后,可以正常编译STM32 的工程,但是无法编译C51的工程,并且出现了如下错误: *** Error: Project ‘template’ requires ‘C51’ Toolchain which is not installe 这种情况就是Keil- 阅读详情


Four Operations

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 79    Accepted Submission(s): 38


Problem Description
Little Ruins is a studious boy, recently he learned the four operations!

Now he want to use four operations to generate a number, he takes a string which only contains digits  '1' -  '9', and split it into  5  intervals and add the four operations '+',  '-',  '*' and  '/' in order, then calculate the result(/ used as integer division).

Now please help him to get the largest result.
 

Input
First line contains an integer  T , which indicates the number of test cases.

Every test contains one line with a string only contains digits  '1'- '9'.

Limits
1≤T≤105
5≤length of string≤20
 

Output
For every test case, you should output  'Case #x: y', where  x indicates the case number and counts from  1 and  y is the result.
 

Sample Input
  
1 12345
 

Sample Output
  
Case #1: 1
 

Source
 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:   5943  5942  5941  5940  5939 
 

Statistic |  Submit |  Discuss |  Note
题意:给你一个字符串,把它分成四块,按顺序把符号+ - * /放上去,问能得到的最大数是多少。

思路:又是一道水题。首先我们看*和/,因为前面有-,所以后面的数要尽可能的小。那么相乘要最小肯定是一位数乘一位数。除的话有两种情况,可能除一位数最小可能除两位数最小,因为一位数乘一位数不可能得到三位数,如果除一个三位数会浪费了一位,然后就是加的部分了,加得到的数最大肯定是一位数加多位数或者多位数加一位数,那么现在答案很明显就只有4种情况,4种求出来取最大就是答案了,下面给代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<utility>
#include<map>
#define maxn 25
typedef long long LL;
using namespace std;
const int mod=1e9+7;;
char s[maxn];
int a[maxn];
LL getnum(int l,int r){
    LL ans=0;
    for(int i=l;i<=r;i++){
        ans=(ans*10)+a[i];
    }
    return ans;
}
int main(){
    int t;
    scanf("%d",&t);
    for(int tcase=1;tcase<=t;tcase++){
        scanf("%s",s);
        int len=strlen(s);
        for(int i=0;i<len;i++){
            a[i]=s[i]-'0';
        }
        LL ans=a[0]+getnum(1,len-4)-a[len-3]*a[len-2]/a[len-1];
        ans=max(ans,getnum(0,len-5)+a[len-4]-a[len-3]*a[len-2]/a[len-1]);
        if(len>5){
            int div=getnum(len-2,len-1);
            ans=max(ans,a[0]+getnum(1,len-5)-a[len-4]*a[len-3]/div);
            ans=max(ans,getnum(0,len-6)+a[len-5]-a[len-4]*a[len-3]/div);
        }
        printf("Case #%d: %lld\n",tcase,ans);
    }
}


三极管特性曲线看不懂?手把手教你用Multisim仿真分析放大电路频率响应 本文针对模拟电路初学者,详细讲解如何利用Multisim软件进行电路仿真,将抽象的三极管特性曲线与放大电路频率响应分析变得直观可视。通过手把手教学,指导读者从导入三极管SPICE模型、仿真输出特性曲线,到分析动态工作点,最终使用波特图仪深入分析频率响应并进行补偿设计,有效帮助理解电路原理并指导实践调试。 阅读详情

相关推荐

STM32F103 超声波风速风向仪实战:0.1m/s精度风洞标定与OLED显示(附源码)

本文详细介绍了基于STM32F103的超声波风速风向仪设计与实现,通过超声波时间差测量技术实现0.1m/s高精度测量。文章涵盖硬件设计、算法实现、风洞标定及OLED显示等关键环节,提供完整源码,适用于气象监测、风力发电等领域。

weixin_42532938的博客 279

Four Operations (枚举)

Little Ruins is a studious boy, recently he learned the four operations! Now he want to use four operations to generate a number, he takes a string which only contains digits ‘1’ - ‘9’, and split it into 5 intervals and add the four operations ‘+’, ‘-’, ‘*

Ditto_xff的博客 293

Dify沙箱权限配置实战:解决‘operation not permitted‘报错的完整指南

本文详细解析了Dify平台中常见的'operation not permitted'报错根源,即沙箱安全机制对系统调用的限制。通过实战步骤,指导用户定位并修改config.yaml配置文件,精准配置allowed_syscalls白名单以解决权限问题,涵盖从文件操作、进程控制到网络通信等关键系统调用的编号详解与配置示例,帮助用户在保障安全的前提下,顺利运行依赖特定库的代码工作流。

tech5的博客 1215

Codeforces Round #742 (Div. 2) F. One-Four Overload

F. One-Four Overload 题意: 给你n∗mn*mn∗m的网格,n<=500,m<=500n<=500,m<=500n<=500,m<=500,有些格子是‘X’,有些格子是‘.’,题目保证网格的最外围一圈都是‘.’,现在我们需要在‘.’的格子中填1或者0,‘X’上的值,是它上下左右,四个方向的‘.’的格子的权值和。 问有没有一种填色方案,使得所有‘X’格子上的值都是5的倍数。有的话,输出构造方案。 思路: 比较显然的思路,我们按照‘X’格子四个方向上‘.’

qq_52383696的博客 198

STM32 HAL库定时器中断实现步进电机S型加减速控制与脉冲精准计数

本文详细介绍了如何使用STM32 HAL库定时器中断实现步进电机的S型加减速控制与脉冲精准计数。通过CubeMX配置定时器、计算PSC和ARR值,并结合S型曲线算法,实现平滑启停和精准定位。文章还提供了脉冲计数方案和常见问题排查技巧,帮助开发者优化步进电机控制性能。

weixin_29189363的博客 376

【ArcGIS教程】基于DEM数据的洪水淹没分析——提取淹没区并计算淹没区洪水量

使用ArcGIS开展洪水淹没区分析、提取淹没区并计算淹没区洪水量的详细说明,如果想获取教程中实验数据,请关注微信公众号【GIS小能手】然后在后台留言。

weixin_45469245的博客 6846

2-sat (CodeForces - 1567F F. One-Four Overload)

CodeForces - 1567F F. One-Four Overload F. One-Four Overload 题目: 给你个网格, X为染色的,.为没染色的,对于没染色的位置只能是111或444,染色的位置为上下左右未染色的位置上值和,并且要求染色的部分的值为5的倍数。要求构造一组解 例: input: 5 5 … .XXX. .X.X. .XXX. … output: YES 4 1 4 4 1 4 5 5 5 1 4 5 1 5 4 1 5 5 5 4 1 4 4 1 4 思路

weixin_50462620的博客 321

Coppelia Sim (v-REP)仿真 机器人3D相机手眼标定与实时视觉追踪 (一)

先把这连个都添加到场景中,然后把kinect的depth相机拖到vision sensor中,把kinect的script也拖到vision sensor中,同时要注意修改深度相机的坐标,及修改script,删掉/rgb部分。由于需要导入到仿真场景中PDF文件不能直接导入,所以需要生成图下文件,使用windows自带的画图工具,生成以厘米为单位的图像格式,大小和标定板的设置大小一直。可以生成需要用的标定板的文件,设置标定板的大小,棋盘格的大小,等相关的参数,之后可以保存PDF文件。设置plane的大小。

hong3731的专栏 1756

hdu 5938 Four Operations【贪心】

Four Operations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Little Ruins is a st

mengxiang000000 1604

足球赛事数据API:开发者生存指南(附真实踩坑记录)

作为一个既爱看球又爱写代码的老宅男,我这些年用过的足球API比看过的比赛还多。从最初被各种API文档折磨到怀疑人生,到现在能闭着眼睛调接口,中间的血泪史够写本书了。今天就把这些经验(和教训)分享给各位同好,特别是那些正在为"老板要做个足球App"而秃头的同行们。文档清晰免费层可用响应格式规范API-Sports免费额度大方支持GraphQL有中文文档(难得!Sportmonks数据全面有Webhook支持按需付费。

Happy0970的博客 2214

uniapp 全局弹窗

功能详解1.有的组件需要全局调用,不想要在一个页面里面一个个引入,现在就需要写入到全局中,直接全局触发。2.通过 $rechargePop就能全局触发 充值的弹窗实现步骤一、先把组件封装好,如 rechargePop组件位置 components/RechargePop/index.vue ,就定义一个methods open方法就可以 二、在同级别路径下定义一个 index.js 三、引入到main.js 四、全局调用this.$rechargePop(); 就能弹出那个弹窗

weixin_42066070的博客 660

hdu5938 Four Operations 贪心

Four Operations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 104    Accepted Submission(s): 49 Problem Description Little Ruins

kyoma的博客 871

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

HDU 5938 && 2016CCPC杭州 F: Four Operations

题意: 将+-x/四个符号按顺序塞入一串字符中,让它成为一个表达式 求表达式能得到的最大值 枚举'-'的位置,'x'一定挨着'-'的后面,'/'一定挨着'x'的后面 然后'+'的位置要不在'-'的前面一个,要不在第一个数后面 #include #include #include using namespace std; #define LL long long char str[

加载中... 393

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

HDU-5938 Four Operations(字符串处理)

Four Operations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 151    Accepted Submission(s): 61 Problem Description Little Ruins is a

huatian5的博客 1063

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

hdu5938Four Operations

链接:http://acm.hdu.edu.cn/showproblem.php?pid=5938 题意:给一个只含'1'~'9'的字符串,要求按顺序插入'+','-','*','/',求运算结果中的最大值。 分析:要求运行结果最大,设为a+b-c*d/e很明显我们能观察到要让前面a+b尽量大即a 代码: #include #include #include #include #inclu

Fsss 949

HDU 5938 Four Operations 想法题

题目描述:Problem Description Little Ruins is a studious boy, recently he learned the four operations!Now he want to use four operations to generate a number, he takes a string which only contains digits ‘

喵头鹰的博客 950

2016CCPC杭州站 F - Four Operations 【枚举】

Little Ruins is a studious boy, recently he learned the four operations! Now he want to use four operations to generate a number, he takes a string which only contains digits ‘1’ - ‘9’, and split it in

Irish_Moonshine的博客 660

Four-Operations

开发环境:Eclipse 结对小伙伴:201306114416 陈键 (http://www.cnblogs.com/be-the-one/) 201306114452 吴舒婷 (http://www.cnblogs.com/wst-2015/) 功能: a)生成题目,单个题目最多不能超过4个运算符,操作数小于100。    b)用户可以输...

weixin_33796205的博客 178

HDU 5938 Four Operations(贪心+细节)——2016年中国大学生程序设计竞赛(杭州)

传送门 Four OperationsTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 69    Accepted Submission(s): 31Problem Description Little Ruins is a studiou

代码改变世界 1472

F - Four Operations(考虑全面)

Little Ruins is a studious boy, recently he learned the four operations!Now he want to use four operations to generate a number, he takes a string which only contains digits ‘1’ - ‘9’, and split it int

梦初始的地方,它也需要生根发芽。 1012

HDU 5938 Four Operations (水题乱搞)

Four OperationsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 413 Accepted Submission(s): 149Problem Description Little Ruins is a studiou

MrBlank的ACM记事本 813

HDU-5938:Four Operations(DP)

HDU-5938:Four Operations(DP)Little Ruins is a studious boy, recently he learned the four operations! Now he want to use four operations to generate a number, he takes a string which only contains digits '1' - '9', and split it into 5 intervals and add the

Mitsuha_的博客 676

hdu 5938 贪心 策略(2016年中国大学生程序设计竞赛(杭州))

做完这道题,感觉自己的实力实在是low。本来是一道水题,但却始终不能ac,还有几次超时。。。。。。 刚开始我是用c++的string来写的,但是一直超时,无奈之下,改用c的字符串(好久不用)。 先说一下这道题的大意,题目说给一串数字,然后在串里选四个空隙(长度一定大于5),依次填入+     -   *     /四个运算符,然后问你运算最大结果是多少。 首先,我们来看,减号会将这个数字分为

zyy.cpp 的博客 543

HDU5938+贪心+(2016年中国大学生程序设计竞赛(杭州))

Four Operations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1574    Accepted Submission(s): 457 Problem Description Little Ruin

hyyjiushiliangxing的博客 577

HDU 5938 Four Operations(暴力+贪心)

Problem Description Little Ruins is a studious boy, recently he learned the four operations! Now he want to use four operations to generate a number, he takes a string which only contains digits'1'-'9', and split it into5intervals and add the four op...

DovahkiinGA的博客 188

hdu 5938 Four Operations

Four Operations Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4690Accepted Submission(s): 1349 Problem Description Little Ruins is a...

Ven 297
上一篇: 2016ccpc杭州赛 hdu 5935 C.Car
下一篇: 2016ccpc杭州赛 hdu 5934 B.Bomb
overload1997
博客等级 码龄11年 328粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值