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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.