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. scala 入门(1)

    大数据“火”的有段日子了,原来打算学习hadoop…… 后知道spark要比hadoop更牛, 故而转学spark.其原码为scala所写,为了更好的研究spark,故又开始学习scala. 将自己所 ...

  2. PCB正片和负片有什么区别

    概念:正片和负片是底片的两种不同类型. 正片:简单地说就是,在底片上看到什么就有什么. 负片:正好相反,看到的就是没有的,看不到的就是有的.见下图: 在 Allegro中使用正负片的特点: 正片:优点 ...

  3. windows批处理命令教程

      批处理文件是无格式的文本文件,它包含一条或多条命令.它的文件扩展名为 .bat 或 .cmd.在命令提示下键入批处理文件的名称,或者双击该批处理文件,系统就会调用Cmd.exe按照该文件中各个命令 ...

  4. Qt自定义sleep延时函数(巧妙的使用时间差,但这样似乎CPU满格,而不是沉睡)

    Qt不像VC++的win32/MFC编程那样,提供了现成的sleep函数可供调用.Qt把sleep函数封装在QThread类中.子线程可以调用sleep函数.但是如果用户想在主线程实现延时功能,该怎么 ...

  5. NSIS Installer(被NSI脚本编译出来的target)获取命令行参数

    References: http://stackoverflow.com/questions/6185982/accessing-command-line-arguments-in-nsis http ...

  6. Linux Shell逻辑运算符和表达式详解

    Shell 逻辑运算符涉及以下几种类型,只要适当选择,可以解决我们很多复杂的判断,达到事半功倍效果. 一.逻辑判断1.关于文件与目录的逻辑判断-f 常用.判断『文件』是否为普通文件,比如: if [ ...

  7. 2014.7.7 模拟赛【小K的农场】

    3.小K的农场(farm.pas/cpp/c) [题目描述] 小K在MC里面建立很多很多的农场,总共n个,以至于他自己都忘记了每个农场中种植作物的具体数量了,他只记得一些含糊的信息(共m个),以下列三 ...

  8. socketFunction

    socket     socket() 我们使用系统调用socket()来获得文件描述符: #include<sys/types.h> #include<sys/socket.h&g ...

  9. BootStrap学习之先导篇——响应式网页

    Bootstrap学习之前,要知道响应式网页的原理. 1.什么是响应式网页? 一个页面,可以根据浏览设备的不同,以及特性的不同,而自动改变布局.大小等.使得在不同的设备上上都可以呈现优秀的界面. 优点 ...

  10. Laravel-路由-控制器

    (慕课网_轻松学会Laravel-基础篇_天秤vs永恒老师) 一.基础路由 二.多请求路由 三.参数路由 四.路由别名 生成url可以使用别名 五.路由群组 六.路由输出视图 七.控制器参数绑定