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;


}

Share on Google Plus
Earn @ Wap4dollar.Com

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.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment