LightOJ 1078 Integer Divisibility Solution



 Problem Link:  https://lightoj.com/problem/integer-divisibility

Solution in C++:

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,t,ts,d,a,cn;
    cin>>t;
    for(ts=1; ts<=t; ts++)
    {
        cin>>d>>n;
        cn=a=0;
        while(1)
        {
            a=((a*10)+n)%d;
            cn++;
            if(a==0)
                break;
        }
        cout << "Case " <<ts<< ": "<<cn<<endl;
    }
}


No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.