LightOJ 1214 Large Division





Find Tutorial Here: Big Integer Remainder

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long int n,r,t,j,i,m;
    //freopen("1214.txt","r",stdin);
    //freopen("1214out.txt","w",stdout);
    cin>>t;
    for(i=1;i<=t;i++)
    {
        cin>>s>>n;
        r=0;
        //cout<<n<<endl;
        if(n<0)
        {
          m=n*(-1);
          //cout<<m<<endl;

        }
        else
        {
            m=n;
        }

        for(j=0;j<s.length();j++)
        {
            if(s[j]!='-')
            {
                r=((r*10)+(s[j]-'0'))%m;
            }

        }
       // cout<<r<<endl;
        if(r==0)
        {
            printf("Case %lld: divisible\n",i);
        }
        else
        {
            printf("Case %lld: not divisible\n",i);
        }
    }
    return 0;


}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment