LightOJ 1354 IP Checking Solution



 Problem Link: https://lightoj.com/problem/ip-checking

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 binaryToDecimal(int n)
{
    int num = n;
    int dec_value = 0;
    int base = 1;
    int temp = num;
    while (temp)
    {
        int last_digit = temp % 10;
        temp = temp / 10;
        dec_value += last_digit * base;
        base = base * 2;
    }
    return dec_value;
}
int main()
{
    int  n,t,i,k=1,a,b,a1,a2,b1,b2,c1,c2,d1,d2;
    char s[1];
    cin>>t;
    while(t--)
    {
        scanf("%d%c%d%c%d%c%d",&a1,&s,&b1,&s,&c1,&s,&d1);
        scanf("%d%c%d%c%d%c%d",&a2,&s,&b2,&s,&c2,&s,&d2);
        a2=binaryToDecimal(a2);
        b2=binaryToDecimal(b2);
        c2=binaryToDecimal(c2);
        d2=binaryToDecimal(d2);
        if(a1==a2&&b1==b2&&c1==c2&&d1==d2)
            printf("Case %d: Yes\n",k++);
        else
            printf("Case %d: No\n",k++);
    }
    return 0;
}



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.