Tuesday, March 27, 2018

DCP-473: Next Perfect Square Number

https://devskill.com/CodingProblems/ViewProblem/473


#include<bits/stdc++.h>

#define  sf scanf
#define pf printf

// Nayeem Mollick Joy , Applied Physics & Electronic Engineering , University of Rajshahi.

using namespace std;

int main(){

    int t;

    long long  n,r;

    sf ("%d",&t);

    while (t--)
    {
        sf ("%lld",&n);

        r = floor(sqrt(double(n)))+1;

        pf ("%lld\n",r*r);
    }
}

Monday, March 26, 2018

DCP-500: Wink or Kick Devskill Problem Solution


https://devskill.com/CodingProblems/ViewProblem/500


#include<bits/stdc++.h>

using namespace std;

int main()

{
   unsigned long long int A,B;
   int t;
   scanf("%d",&t);
   while(t--)
   {
       cin>>A>>B;
       if(B==0)
       {
           printf(":kick:\n");
       }
       else if(A%B==0)
       {
           printf(":wink:\n");
       }
       else
       {
           printf(":kick:\n");
       }

   }
   return 0;
}

DCP-420: Minimum Cost Devskill Problem Solution

https://devskill.com/CodingProblems/ViewProblem/420

#include<bits/stdc++.h>

// Nayeem Mollick Joy , Applied Physics & Electronic Engineering , University of Rajshahi.

using namespace std;

int main()

{
    vector<int>joy;
    int t,n,i,count;
    cin>>t;
    while(t--)
    {
        cin>>i;
        while(i--)
        {
            cin>>n;
            joy.push_back(n);
        }
        count=0;
        sort(joy.begin(),joy.end());
        int mn=joy[0];
        vector<int>::iterator iter=joy.begin();
        for(iter;iter!=joy.end();iter++)
        {
            count=count+((*iter)-mn);
        }
        cout<<count<<endl;
        joy.clear();
    }
    return 0;
}