codeforces——313A——Ilya and Bank Account
来源:互联网 发布:制作淘宝无缝拼接主图 编辑:程序博客网 时间:2024/06/14 07:54
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.
The single line contains integer n (10 ≤ |n| ≤ 109) — the state of Ilya's bank account.
In a single line print an integer — the maximum state of the bank account that Ilya can get.
2230
2230
-10
0
-100003
-10000
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.
可以删掉最后一个数或者倒数第二个数也可以不删,问在哪种情况资产最大
水,写的有点长,本来想着往数组里套,以简短代码,后来想着没必要就没有改
#include<iostream>#include<algorithm>#include<stdio.h>#include<cstring>using namespace std;int main(){ int n; while(cin>>n!=NULL) { if(n<0) { char s[20]; sprintf(s,"%d",n); int n2=strlen(s); s[n2-1]='\0'; int x1; sscanf(s,"%d",&x1); sprintf(s,"%d",n); s[n2-2]=s[n2-1]; s[n2-1]='\0'; int x2; sscanf(s,"%d",&x2); n=(x1>x2?x1:x2); } cout<<n<<endl; } return 0;}
- codeforces——313A——Ilya and Bank Account
- codeforces 313A - Ilya and Bank Account
- CodeForces-313A Ilya and Bank Account
- Codeforces Ilya and Bank Account
- A. Ilya and Bank Account
- Ilya and Bank Account
- CF:Ilya and Bank Account
- codeforces A. Ilya and Diplomas
- Codeforces Round #293 (Div. 2)D.Ilya and Escalator——概率dp
- CodeForces#311 A. Ilya and Diplomas
- Codeforces 557A Ilya and Diplomas 【水题】
- CodeForces 557A-Ilya and Diplomas【模拟】
- CodeForces 557A Ilya and Diplomas
- CodeForces - 557A Ilya and Diplomas
- CodeForces 557A Ilya and Diplomas
- 【55.70%】【codeforces 557A】Ilya and Diplomas
- codeforces 313B Ilya and Queries
- codeforces 313C. Ilya and Matrix
- myeclipse或eclipse引入mybatis
- 最长公共子序列问题(LCS)
- python中的reduce函数
- 高通源码下载2----用从高通下载的repo
- Git简介
- codeforces——313A——Ilya and Bank Account
- 10个常用PHP代码片段总结
- 程序员这样优化简历,一投制胜
- 如何通过pandas.apply进行整列和整行计算,以及如何处理A value is trying to be set on a copy of a slice from a DataFrame.错误
- java 从服务器下载文件并保存到本地
- Eclipse设置程序编译运行前自动保存
- Linux特训之vi编辑器part 2(进阶练习)
- JAVA中的Object类和System类
- 【正一专栏】从政治学看足协新政