UVa Problem Solution 11371 – Number Theory for Newbies

Problem Solving, UVa

 

 

#include <bits/stdc++.h>

using namespace std;

int main()

{

    string n,a;

long long s,b,c,d,l;

while(cin>>n)

{

    sort(n.begin(),n.end());

    a=n;

     if(a[0]=='0')

        {

            for(int i=1;i<n.size();i++)

            {

                if(a[i]!='0')

                {

                    swap(a[0],a[i]);

                    break;

                }

            }

        }

    reverse(n.begin(),n.end());

    b=atoll(n.c_str());

    c=atoll(a.c_str());

    if(b<c)

    swap(b,c);

    s=b-c;

    d=s/9;

    printf("%lld - %lld = %lld = 9 * %lld\n",b,c,s,d);

}

return 0;

}

 

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...