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. 基于JDK6的JAX-WX为客户端提供XML与JSON格式数据服务,以及客户端采用AXIS调用案例

    1:WebService服务端工程目录如下: 需要第三方jar包:gson-2.2.4.jar\javax.xml.bind.jar\commons-lang-2.5.jar 源码如下: packag ...

  2. POJ 1225 Substrings

    http://poj.org/problem?id=1226 题意:给定n个串.求一个最长的串,使得这个串或者其反串在每个串中都出现过? 思路:先在大串里面加入正反串,然后二分,判定即可. #incl ...

  3. Android项目使用support v7时遇到的各种问题

    Android项目使用support v7时遇到的各种问题 点击你的工程右键-->Properties-->Android 1.查看你引用的appcompat_v7包是否引用正确 2.用较 ...

  4. vbox安装mac os x

    http://zhiwei.li/text/2013/12/%E5%9C%A8virtualbox4-3-4%E4%B8%AD%E5%AE%89%E8%A3%85mavericks/ http://g ...

  5. 2015第19周三小众app

    今天搜集下个人知道好玩的小众app: 1.开眼每日推荐5个小视频,世界那么大,一起来看看吧. 2.懒人周末周末去哪了?简洁美观 3.LOFTER 网易良心出品. 4.玩儿去 发现很多很多好玩的去处 5 ...

  6. EBS Workfow常用表

    1.Workflow Definition Tables WF_ITEM_TYPES WF_ACTIVITIES WF_MESSAGES WF_ITEM_ATTRIBUTES WF_ACTIVITY_ ...

  7. 一个session已经ACTIVE20多小时,等待事件SQL*Net more data from client

    问题描述: 一个session已经ACTIVE20多小时,等待事件SQL*Net more data from client 有一人session,从昨天上午11点多登陆(v$session.logi ...

  8. MySQL数据库 常用操作

    1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql> SHOW DATABASES; 2:创建一个数据库MYSQLDATA mysql> CREATE DATABASE M ...

  9. 关于初学者上传文件到github的方法

    转:http://blog.csdn.net/steven6977/article/details/10567719 说来也惭愧,我是最近开始用github,小白一个,昨天研究了一个下午.终于可以上传 ...

  10. EL表达式使用之类switch语句

    http://blacksonny.iteye.com/admin/blogs/1879878