UVA 10212 The Last Non-zero Digit Solution

 Solution in c++:
     ///**********ALLAH IS ALMIGHTY************///
     ///AH Tonmoy
    ///Department of CSE,23rd batch
    ///Islamic University,Bangladesh

#include<iostream>
#define int64 long long int
using namespace std;
int main()
{
    int64 n,m;
    while(cin>>n>>m)
    {
        if(m==0)
            cout<<"1"<<endl;
        else
        {
            int64 ans,i;
            ans=1;
            for(i=n; i>=n-m+1; i--)
            {
                ans*=i;
                while(ans%10==0)
                {
                    ans=ans/10;
                }
                    ans=ans%1000000000;

            }
            cout<<ans%10<<endl;
        }
    }
}

1 comment:

  1. Okay then...

    What I'm going to tell you may sound really weird, and maybe even a little "out there..."

    WHAT if you could just hit "PLAY" and LISTEN to a short, "magical tone"...

    And suddenly attract MORE MONEY into your LIFE?

    What I'm talking about is hundreds... even thousands of dollars!

    Sounds way too EASY? Think it's IMPOSSIBLE?!?

    Well, Let me tell you the news...

    Sometimes the most magical blessings life has to offer are the easiest to RECEIVE!

    In fact, I'm going to PROVE it to you by letting you listen to a REAL "magical money-magnet tone" I've synthesized...

    You just press "PLAY" and watch as your abundance angels fly into your life... starting so fast, you will be surprised...

    CLICK here now to experience this marvelous "Miracle Money Sound Frequency" - as my gift to you!

    ReplyDelete

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.