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. injector

    angular 提供了一套依赖注入的机制,和后台很像.虽然我不觉得有很重要. var $injector = angular.injector(["myModule"]); var ...

  2. MVC每层的职责

    MVC模式把应用程序分割成三层:模型.视图和控制器. 模型:模型代表着核心的业务逻辑和数据.模型封装了域实体的属性和行为,并暴露出了实体的属性. 视图: 视图负责转换模型并把它传递给表示层.视图应关注 ...

  3. C#反射 获取程序集信息和通过类名创建类实例(转载)

    C#反射获取程序集信息和通过类名创建类实例 . System.Reflection 命名空间:包含通过检查托管代码中程序集.模块.成员.参数和其他实体的元数据来检索其相关信息的类型. Assembly ...

  4. AIX和Linux中wtmp的不同处理方式

    wtmp 记录用户登录和退出事件.它和utmp日志文件相似,但它随着登陆次数的增加,它会变的越来越大,有些系统的ftp访问也在这个文件里记录,同时它也记录正常的系统退出时间,可以用ac和last命令访 ...

  5. pidof,pgrep进程名查PID, /proc目录由pid查进程名

    pidof,pgrep进程名查PID cat /proc/4990/status|grep "name",由pid查进程名

  6. hdu 1874 畅通工程续(最短路)

    最短路问题! 最简单的最短路问题! 恩! #include<stdio.h> #define MAX 1000000 int map[500][500]; int n,m,start,en ...

  7. Android去除系统自带动画的两种方法

    方法一: 在startActivity()或者finish()后紧跟调用: ((Activity) mContext).overridePendingTransition(0, 0); 方法二: 在一 ...

  8. c语言结构体5之匿名结构体

    注意: 1匿名结构体不会出现重合 重命名的情况 2有名结构体 名称不能相同 也就是不能重名 //匿名结构体不会出现重名的情况 struct //无名结构体 { ]; ]; int num; };//不 ...

  9. IO中手机旋转事件的传递

    UIApplication -> delegate -> widnow -> rootViewController

  10. javascsript 去除数组重复数据

    function uniqid(arr){ var newArr = []; var c; for(var i = 0 ;i <= arr.length ;i++){ c = false; fo ...