Giter Club home page Giter Club logo

chocolate's Introduction

import java.util.; import java.io.; import java.lang.*; //This code is generated by Ritu Rao Patibandla

/* Suppose a teacher has chocolate bars in the sizes such that the minwidth and maxwidth and of minheight and maxheight. The teacher has to distribute the chocolates to the students only when the chocolate is a square,that means suppose if she has the chocolate bars of minwidth=2 and maxwidth=4 and minheight=3 and maxheight=6, then she has bars of sizes (2,3),(2,4),(2,5),(2,6),(3,3),(3,4),(3,5),(3,6),(4,3),(4,4),(4,5),(4,6); she can give the chocolate to a student if the width and height of the chocolate is same, and if not then she will break the chocolate to make it square such as (2,3) can be broken down into (2,2) and(2,1) and later (2,1)will be broken down into (1,1) and (1,1).

eg. input 1 3 1 2 output 12 how many kids will get the chocolate for given input? */ class Chocolate { public static void main(String args[]) { int i,j,k,l,x,y,ccount=0; Scanner a=new Scanner(System.in); Scanner b= new Scanner(System.in); Scanner c= new Scanner(System.in); Scanner d= new Scanner(System.in); i=a.nextInt(); j=b.nextInt(); k=c.nextInt(); l=d.nextInt();

for (x=i;x<=j;x++){
  for (y=k;y<=l;y++){
   ccount=small(x,y,ccount); 
  }
  }
System.out.println(ccount);

}

public static int small(int a,int b,int c){ int min,max,count=c,a11; if(a==b){ count=count+1; } else if(a!=b) { min=Math.min(a,b); max=Math.max(a,b); a11=max-min; count=small(min,min,count); count=small(a11,min,count); } return count; } }

chocolate's People

Contributors

riturao avatar

Watchers

 avatar

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.