Friday, October 9, 2015

1214 - Large Division (LightOJ)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;

int main()
{
    //freopen("in.txt" , "r", stdin);
    string a;
    long long b, rem;
    int test, t, i;
    cin>> test;
    for(t=1; t<=test; t++)
    {
        cin >> a >> b;
        if(b<0)
            b = b*(-1);
        int len = a.length();
        rem=0;
        for(i=0; i<len; i++)
        {
            if(a[i]=='-')
                i=1;
            rem*=10;
            rem+=(a[i]-'0');
            rem%=b;
        }
        if(rem==0)
            printf("Case %d: divisible\n", t);
        else
            printf("Case %d: not divisible\n", t);
    }
}

1 comment:

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...