Code Monkey home page Code Monkey logo

problem-tutorials's People

Contributors

ar-pavel avatar arafat1802 avatar aref111n avatar arfaqur-rahman avatar dristy03 avatar evan-cse avatar faiyaz26 avatar im-nayeem avatar istiaqueshubho avatar jan876 avatar mahedikamal avatar munmud avatar mussabat avatar nfpranta avatar rahathossain690 avatar raiyan-98 avatar raselmeya94 avatar rebornplusplus avatar robinhood3082 avatar saif-2019331014 avatar sakib3201 avatar sayeed1999 avatar showrav-ansary avatar solaimanope avatar subhashiscse avatar tahanima avatar talha-taki002 avatar tanvirsojal avatar tstanvir avatar walleeva2018 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

problem-tutorials's Issues

LOJ 1001 - Opposite Task

LOJ 1001 - Opposite Task

You have given a number n. If n can be written as addition of two positive integers such as, n = a+b then print the value of a and b. Any value of a and b that follow the equation is accepted.

C


#include <stdio.h>
int main()
{
    int test, num;
    scanf("%d", &test);
    while(test--){
        scanf("%d", &num);
        if(num > 10){
            printf("%d ", 10);
            num = num - 10;
        }
        else printf("0 ");
        printf("%d\n", num);
    }
    return 0;
}

Add tutorial for LOJ-1069 : Lift

Problem: You are given what floor you are on and what floor the lift is on. You need to calculate how many seconds you will need to get to ground floor.

Assume that it takes 4 seconds for the lift to go from any floor to its adjacent floor (up or down). It takes 3 seconds to open or close the door of the lift and you need 5 seconds to enter or exit the lift.

That means you need to calculate the total time, T = time needed by the lift to come to your floor + time needed by the lift door to open + time needed by you to enter the lift + time needed by the lift door to close + time needed by the lift to reach ground floor + time needed by the lift door to open again + time needed by you to exit the lift.

Here,

  • time needed by the lift to come to your floor = abs(myPosition-liftPosition) * 4sec

  • time needed by the lift door to open = 3sec

  • time needed by you to enter the lift = 5sec

  • time needed by lift door to close = 3sec

  • time needed by the lift to reach ground floor = myPosition * 4sec

  • time needed by the lift door to open again = 3sec

  • time needed by you to exit the lift = 5sec

C++


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

int main(){
    int testcase; 
    cin>>testcase;
    
    for(int t=1; t<=testcase; t++){
        int myPosition, liftPosition;
        cin>>myPosition>>liftPosition;
      
        int timeTakenByMeToEnter=5;
        int timeTakenByMeToExit=5;
        int timeTakenByLiftToOpen=3;
        int timeTakenByLiftToClose=3;
        int timeTakenByLiftToReachMyFloor= abs(myPosition-liftPosition)*4; // If lift was on floor 8 and I was on floor 2, (2-8)=-6. To avoid the minus sign, we used the abs() function. As lift takes 4 seconds to reach the adjacent floor, we multiply by 4.
        int timeTakenByLiftToReachGroundFloorFromMyFloor=(myPosition)*4; //Lift takes 4 seconds to go from one floor to the next floor. That's why we multiply by 4.
        
        cout<<"Case "<<t<<": "<<  abs(myPosition-liftPosition)*4 + timeTakenByLiftToOpen + timeTakenByMeToEnter + timeTakenByLiftToClose + (myPosition)*4 + timeTakenByLiftToOpen + timeTakenByMeToExit<<endl;
    }
}

Happy Coding!

Add tutorial for 1010 - Knights in Chessboard

Chess board knights only travel in L shaped squares.

In this problem there are 3 cases mainly considerable.

  • Case 1: If any of the rows or columns is 1 then there is no L shaped formed. So answer is max of row and column.See the pic for better understanding.

  • Case 2: If rows and columns are greater then 2 then just half the total of squares is the answer.

  • Case 3:(most important case) If either of the row or column is 2 then we just divide the total squares by 8 where 1st 4 blocks can be placed by knights and other 4 blocks are forbidden. See the pic for better understanding.
    The remaining blocks(if any) if less then or equals 4 then remaining blocks are added to the answer and if greater then we add 4 to the answer.

        int n,m;
        cin>>n>>m;
        if(m==1 or n==1)
        {
            cout<<"Case "<<i<<": "<<max(n,m)<<endl;
        }
        else if(n==2 or m==2)
        {
            cout<<"Case "<<i<<": "<<((m*n)/8)*4 + (((m*n)%8)>=4?4:(m*n)%8)<<endl;
        }
        else
        {
            cout<<"Case "<<i<<": "<<(n*m+1)/2<<endl;
        }

Light 1001 for duplicate case

The main problem with the website said that the user couldn't print duplicate numbers. But there haven't any also for merging the same number

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.