A. Ilya and Bank Account
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can be a negative number. This means that the owner of the account owes the bank money.

Ilya the Lion has recently had a birthday, so he got a lot of gifts. One of them (the gift of the main ZooVille bank) is the opportunity to delete the last digit or the digit before last from the state of his bank account no more than once. For example, if the state of Ilya's bank account is -123, then Ilya can delete the last digit and get his account balance equal to -12, also he can remove its digit before last and get the account balance equal to -13. Of course, Ilya is permitted not to use the opportunity to delete a digit from the balance.

Ilya is not very good at math, and that's why he asks you to help him maximize his bank account. Find the maximum state of the bank account that can be obtained using the bank's gift.

Input

The single line contains integer n (10 ≤ |n| ≤ 109) — the state of Ilya's bank account.

Output

In a single line print an integer — the maximum state of the bank account that Ilya can get.

Sample test(s)
input
2230
output
2230
input
-10
output
0
input
-100003
output
-10000
Note

In the first test sample Ilya doesn't profit from using the present.

In the second test sample you can delete digit 1 and get the state of the account equal to 0.

题解:求删除某个数字最后两位中的一位后让剩下的数最大,当然该数为正数的时候是不需要删除任何数字的,该数为负数时需要判断是删除最后一位还是倒数第二位,分别计算出这两种情况下剩下的值,比较大小即可。

题目地址:http://codeforces.com/contest/313/problem/A

代码:

 #include<stdio.h>
#include<string.h>
#include<stdlib.h> int i,j,n; char a[],b[],c[];
int
pre()
{
memset(a,'\0',sizeof(a));
memset(b,'\0',sizeof(b));
return ;
} int
init()
{ scanf("%s",a);
if(a[]!='-')
{
printf("%s",a);
exit();
} return ;
} int
main()
{
pre();
init(); if(strlen(a)==)
{
if(a[]=='')
{
printf("");
exit();
}
if(a[]>a[])
printf("-%c",a[]);
else printf("-%c",a[]); exit();
} for(i=;i<=strlen(a)-;i++)
{
b[i-]=a[i];
c[i-]=a[i];
} b[strlen(a)-]=a[strlen(a)-];
c[strlen(a)-]=a[strlen(a)-]; if(strcmp(b,c)<)
printf("-%s",b);
else printf("-%s",c); return ;
}

[Codeforces Round #186 (Div. 2)] A. Ilya and Bank Account的更多相关文章

  1. 递推 Codeforces Round #186 (Div. 2) B. Ilya and Queries

    题目传送门 /* 递推:用cnt记录前缀值,查询区间时,两个区间相减 */ #include <cstdio> #include <algorithm> #include &l ...

  2. [Codeforces Round #186 (Div. 2)] B. Ilya and Queries

    B. Ilya and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心

    Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  4. 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

    题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...

  5. Codeforces Round #186 (Div. 2)

    A. Ilya and Bank Account 模拟. B. Ilya and Queries 前缀和. C. Ilya and Matrix 考虑每个元素的贡献. 边长为\(2^n\)时,贡献为最 ...

  6. Codeforces Round #311 (Div. 2) A. Ilya and Diplomas 水题

    A. Ilya and Diplomas Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/ ...

  7. Codeforces Round #430 (Div. 2) C. Ilya And The Tree

    地址:http://codeforces.com/contest/842/problem/C 题目: C. Ilya And The Tree time limit per test 2 second ...

  8. Codeforces Round #293 (Div. 2) D. Ilya and Escalator 概率DP

    D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  9. Codeforces Round #186 (Div. 2).D

    纠结的一道dp. 状态转移方程还是比较好想的,优化比较纠结 D. Ilya and Roads time limit per test 3 seconds memory limit per test ...

随机推荐

  1. 局域网架个YUM源-HTTP的

    在安装CDH时,这是个绕不过去的坎. 参考URL: http://www.21ops.com/linux/26465.html 奇怪的是,我并没执行creatrepo这个,直接将光盘MOUNT来用的. ...

  2. 段错误bug的调试

    我们在用C/C++语言写程序的时侯,内存管理的绝大部分工作都是需要我们来做的.实际上,内存管理是一个比较繁琐的工作,无论你多高明,经验多丰富,难 免会在此处犯些小错误,而通常这些错误又是那么的浅显而易 ...

  3. cxSplitter.HotZone 怎么给分隔条增加值

    请使用它的类名指定HotZoneClassName . cxSplitter1.ResizeUpdate := True; cxSplitter1.HotZoneClassName := 'TcxMe ...

  4. usaco5.5-Picture

    离散化计算重叠矩形的周长. 称平行于x轴的边为横边,我们以横边为例,某一矩形中y坐标比较小的横边我们称为始边,另一边我们称为终边.用一条扫描线从下往上扫描,当扫到一条始边的时候,如果这条始边的正下方出 ...

  5. 一、mysql分表简单介绍

    一.Mysql分表的原因 1.当一张的数据达到几百万时,你查询一次所花的时间会变多,如果有联合查询的话,我想有可能会死在那儿了. 分表的目的就在于此,减小数据库的负担,缩短查询时间. 2.mysql中 ...

  6. Hibernate试题解析

    1.在Hibernate中,以下关于主键生成器说法错误的是(AC). A.increment可以用于类型为long.short或byte的主键(byte类型不可以) B.identity用于如SQL ...

  7. 在Windows7上搭建Cocos2d-x win32开发环境

    很多其它相关内容请查看本人博客:http://www.bokeyi.com/ll/category/cocos2d-x/ 建议:为了避免安全相关的问题,请以管理员权限执行全部的操作,当执行命令的时候, ...

  8. 使用apktool解包和打包apk

    使用apktool解包和打包apk 下载apktool工具 解包 apktool d xxx.apk -f 植入代码 使用apktool解包要植入代码的apk(下面称为A), 使用apktool解包包 ...

  9. Request.Params用法

    使用Request.Params["id"]来获取参数是一种比较有效的途径.有三种方式可以进行参数传递:(1). Form (2). ?id= (3).cookierequest. ...

  10. _js day12