CodeChef Logo CodeChef Logo
Courses

Programming and DSA

Learn to think like a programmer. Develop your problem-solving skills with essential data structures and algorithms.

Career Paths

From beginner to job-ready. Explore our curated career paths designed to help you succeed in the tech industry.

Other Courses

Programming and DSA

Explore courses

Catalogue

Programming and DSA

Learn to think like a programmer. Develop your problem-solving skills with essential data structures and algorithms.

Career Paths

From beginner to job-ready. Explore our curated career paths designed to help you succeed in the tech industry.

Other Courses

Explore courses
Practice Compete Compiler
Upgrade to Pro
Courses

Programming and DSA

Learn to think like a programmer. Develop your problem-solving skills with essential data structures and algorithms.

Career Paths

From beginner to job-ready. Explore our curated career paths designed to help you succeed in the tech industry.

Other Courses

Programming and DSA

Explore courses

Catalogue

Programming and DSA

Learn to think like a programmer. Develop your problem-solving skills with essential data structures and algorithms.

Career Paths

From beginner to job-ready. Explore our curated career paths designed to help you succeed in the tech industry.

Other Courses

Explore courses
Practice Compete Compiler
Home
Practice(hard)

Attack of the Clones

A boolean function is a function of the form f: Bn -> B, where B = {0, 1} and n is a non-negative integer called the arity of the function. Some Boolean functions are projections: pnk(x1, ..., xn) = xk. And given an m-ary function f, and n-ary functions g1, ..., gm, we can construct another n-ary function: h(x1, ..., xn) = f(g1(x1, ..., xn), ..., gm(x1, ..., xn)), called their composition.

  • Login or register to post comments
  • Read more

648629

  • Login or register to post comments

Preferred Cooking Schools

  • Login or register to post comments

629446

  • Login or register to post comments

629441

  • Login or register to post comments

629445

  • Login or register to post comments

Harmonious Decorating

The Chef has formed a very nice planar graph out of icing on his latest cake. The nodes of the graph are represented by distinct points on the cake and every edge is drawn as a straight line segment between its two endpoints. For each edge e = (u,v) the line segment connecting u and v does not pass through any other point representing some other node. Finally, if two line segments representing different edges e,e' share a common point on the cake, it must be that this common point is in fact a common endpoint v of both e and e' (i.e. no two edges cross).

  • Login or register to post comments
  • Read more

Sum Divides Product

For a given positive integer N find the number of all pairs (a, b) of positive integers such that 1 <= a < b <= N and the sum a + b divides the product a * b.

Input

The first line contains a single positive integer T <= 5, the number of test cases. T test cases follow. The only line of each test case contains a positive integer N <= 109.

Output

For each test case, output a single line containing the answer for the corresponding test case.

  • Login or register to post comments
  • Read more

Pruning Trees

You have a tree (an acyclic, connected graph) with edge weights, but it is far too big. You are to prune the tree by deleting some edges so that the following property holds. For each connected component C of the pruned tree, there is some node rC such that for every node v in C, the total weight of the edges on the path between v and rC is at most some given value d.

You happen to like heavy trees so you want to delete the minimum possible total edge weight to satisfy this property.

Input

 

  • Login or register to post comments
  • Read more

624431

  • Login or register to post comments
‹ previous
9 of 25
next ›
Workden, MNR PRIDE, 14, HAL Old Airport Rd, Domlur I Stage, 1st Stage, DOMLUR, Bengaluru, Karnataka 560071 help@codechef.com +91 95911 47880
Find us online

ROADMAPS

Learn Python
Learn Java
Learn C
Learn C++
Data structures and Algorithms
Competitive Programming
More Roadmaps

CAREER PATHS

React JS Developer
Full stack Developer
SQL for Data Analysis
Frontend Developer
Java Backend Developer
Data Analysis using Python
Python Backend Developer
C++ Developer
Machine Learning using Python

COMPILERS

HTML online compiler
C++ online compiler
C online compiler
Java online compiler
Python online compiler
SQL online compiler
JavaScript online compiler
React online compiler
More compilers

COMPANY

About us
For colleges
Coding Contests
Blogs
Contact us
Privacy Policy
Frequently Asked Questions

© 2026 CodeChef Inc. All rights reserved.

We use cookies to improve your experience and for analytical purposes. Read our Privacy Policy and Terms to know more. You consent to our cookies if you continue to use our website.