Tags » Devskill Solution

DCP-421: Divisible Pairs [solved]

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int tn, cn=0;
    scanf("%d", &tn);
    while(tn--)
    {
        int n;
        scanf("%d", &n);
        long long arr[6], a;
        memset(arr, 0, sizeof(arr));
        for(int i=0; i<n; i++)
        {
            scanf("%d", &a);
            arr++;
        }

        long long int ans=0,b,c,d;
        a=b=c=d=0;
        if(arr[0]>1) a=(arr[0]*(arr[0]-1))/2;
        if(arr[3]>1) b=(arr[3]*(arr[3]-1))/2;
        c=(arr[5]*arr[1]);
        d=(arr[4]*arr[2]);
        ans=a+b+c+d;
        printf("%lld\n",ans);
    }
}
Devskill Solution

DCP-303: Fibonacci Divisor

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: http://iuconvergent.wordpress.com
*******************************************/

#include<cstdio>
using namespace std;

int main()
{
    //IOS;
    int tn, n, k;
    scanf("%d", &tn);
    while(tn--)
    {
        scanf("%d%d", &n, &k);
        k/=n;
        printf("%d\n", k);
    }
    return 0;
}
Devskill Solution

DCP-251: Journey By Circle

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/


#include<cstdio>
using namespace std;

template<typename T>inline T Gcd(T a, T b){return b?Gcd(b, a%b):a;}
template<typename T>inline T Lcm(T a, T b){return (a*b)/Gcd(a, b);}

int main()
{

    int tn;
    long long int r1, r2;
    scanf("%d", &tn);
    while(tn--)
    {
        scanf("%lld%lld", &r1, &r2);
        printf("%lld\n", Lcm(r1, r2)*2);
    }
    return 0;
}
Math

DCP-185: Maximum Difference

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include<cstdio>
#include<cmath>
using namespace std;
#define Max(a, b) a<b?b:a

int main()
{

    int tn, tc=1, a1, a2, b1, b2;
    scanf("%d", &tn);
    while(tn--){
        scanf("%d%d%d%d", &a1, &b1, &a2, &b2);

        int mx=0;
        mx=Max(abs(a1-a2), abs(b1-b2));
        mx=Max(mx, abs((a1+b2)-(a2+b1)));
        printf("Case %d: %d\n", tc++, mx);

    }
    return 0;
}
Devskill Solution

DCP-165: Easy Geometry [solved]

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int tn, tc=1;
    scanf("%d", &tn);

    while(tn--)
    {
        int nrow, ncol;
        scanf("%d%d", &nrow, &ncol);
        printf("Case %d: %d\n", tc++, nrow*2+ncol*3);
    }
    return 0;
}
Math

DCP-138: The Last Fibonacci [solved]

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include<bits/stdc++.h>
using namespace std;
#define MX 100000
#define MX2 10000
int arr, arr2;
int main()
{
    int n, tn, tc=1;
    arr[0]=0;
    arr[1]=1;
    for(int i=2; i<=60; i++)
        arr[i]=(arr+arr)%10;
    scanf("%d", &tn);
    while(tn--)
    {
        scanf("%d", &n);
        printf("Case %d: ", tc++);
        if(n<61) printf("%d", arr[n]);
        else printf("%d", arr);
        printf(" is the last digit.\n");
    }
    return 0;
}
Devskill Solution

DCP-23: Another Bigmod Problem [solved]

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include <iostream>
using namespace std;
#define ll long long int
template <typename T>
T mmul(T a, T b, T m) {
    a %= m;
    T result = 0;
    while (b) {
        if (b % 2) result = (result + a) % m;
        a = (a + a) % m;
        b /= 2;
    }
    return result;
}

template <typename T>
T mpow(T a, T b, T m) {
    a %= m;
    T result = 1;
    while (b) {
        if (b % 2) result = mmul(result, a, m);
        a = mmul(a, a, m);
        b /= 2;
    }
    return result;
}
int  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tn, tc=0;
    cin>>tn;
    while(tn--)
    {
        ll a, p, m, res;
        cin>>a>>p>>m;
        res=mpow(a, p, m);
        cout<<"Case "<<++tc<<": "<<res<<endl;
    }
    return 0;
}
Devskill Solution