Friday, 10 February 2017

Light Oj 1078 Integer Divisibility

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll divisor;
ll rem;
ll mod_chk(ll i)
{
    rem=(rem*10+s[i]-'0')%divisor;
    return rem;
}
int main()
{
    ll i,j,k,l,m,n,test;
    scanf("%lld",&test);
    for(k=1;k<=test;k++)
    {
        char c;
        scanf("%lld %c",&divisor,&c);
        s="";
        ll cnt=1;
        s+=c;
        ll in=0;
        rem=0;
        while(mod_chk(in)!=0)
        {
            s+=c;
            cnt++;
            in++;
        }
        printf("Case %lld: %lld\n",k,cnt);
    }
    return 0;
}

No comments:

Post a Comment