Codeforces Round #288 (Div. 2) 508B - Anton and currency you all know Solution


 

Problem Link:  https://codeforces.com/problemset/problem/508/B

Solve in C++:  
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t,i,j,l,a,n,b;
    string s;
    cin>>s;
    l=s.size();
    a=-1;
    for(i=0; i<l; i++)
    {
        if((s[i]-'0')%2==0)
        {
            a=i;
            if(s[i]<s[l-1])
            break;
        }
    }
    if(a==-1)
        cout<<"-1"<<endl;
    else
    {
        swap(s[a],s[l-1]);
        cout<<s<<endl;
    }
}


No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.