313A - Ilya and Bank Account - CodeForces Solution


implementation number theory *900

Please click on ads to support us..

Python Code:

balance=int(input())
if balance<0:
    balance*=-1
    digit1=balance%10
    balance=balance//10
    digit2=balance%10
    balance=balance//10
    if digit1>digit2:
        print(-1*((balance*10)+digit2))
    else:
        print(-1*((balance*10)+digit1))
else:
    print(balance)

C++ Code:

// AUTHOR - MALAY ZALAWADIA
// DATE - 29-01-2022
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i,n) for(ll i=0;i<n;i++)
#define fll(i,n,m) for(ll i=n;i<=m;i++)
#define rl(i,n,m) for(ll i=n;i>=m;i--)
#define py cout<<"YES"<< endl;
#define pn cout<<"NO"<< endl;
#define pi 3.141592653589793238
#define vr(v) v.begin(),v.end()
#define rv(v) v.end(),v.begin()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define MMZ cout.tie(NULL);
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a/gcd(a,b)*b);}
string decToBinary(int n){string s="";int i = 0;while (n > 0) {s =to_string(n % 2)+s;n = n / 2;i++;}return s;}
ll binaryToDecimal(string n){string num = n;ll dec_value = 0;int base = 1;int len = num.length();for(int i = len - 1; i >= 0; i--){if (num[i] == '1')dec_value += base;base = base * 2;}return dec_value;}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
bool nextPrime(ll N){if (N <= 1)return 2;ll prime = N;bool found = false;while (!found) {prime++;if (isPrime(prime)) found = true;}return prime;}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
bool isPerfectSquare(ll x){if (x >= 0) {ll sr = sqrt(x);return (sr * sr == x);}return false;}
ll moduloMultiplication(ll a,ll b,ll mod){ll res = 0;a %= mod;while (b){if (b & 1)res = (res + a) % mod;b >>= 1;}return res;}
ll powermod(ll x, ll y, ll p){ll res = 1;x = x % p;if (x == 0) return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}

void mmz() {
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    /*Code By MMZ
    ll t;
    cin>>t;
    while(t--) {
      mmz();
    }*/
    //mmz();
    ll n;

    while(cin >> n) {
      if(n > 0) {
        cout << n << endl;
        continue;
      }

      ll x = n/10;
      ll y = (n/100)*10 - (abs(n)%10);
      cout << max(x,y);
    }
}


Comments

Submit
0 Comments
More Questions

227B - Effective Approach
1534B - Histogram Ugliness
1611B - Team Composition Programmers and Mathematicians
110A - Nearly Lucky Number
1220B - Multiplication Table
1644A - Doors and Keys
1644B - Anti-Fibonacci Permutation
1610A - Anti Light's Cell Guessing
349B - Color the Fence
144A - Arrival of the General
1106A - Lunar New Year and Cross Counting
58A - Chat room
230A - Dragons
200B - Drinks
13A - Numbers
129A - Cookies
1367B - Even Array
136A - Presents
1450A - Avoid Trygub
327A - Flipping Game
411A - Password Check
1520C - Not Adjacent Matrix
1538B - Friends and Candies
580A - Kefa and First Steps
1038B - Non-Coprime Partition
43A - Football
50A - Domino piling
479A - Expression
1480A - Yet Another String Game
1216C - White Sheet