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 » Wiki » April 2012 Contest Problem Editorials

April 2012 Contest Problem Editorials

Problem Tester for the contest was Hiroto Sekido.

Find a special connected block (written by shangjingbo). The Editorials can be found here.

Double Strings (written by Sergey Kulik). The Editorials can be found here.

Greatest Dumpling Fight (written by ishani parekh). The Editorials can be found here.

Lucky Array (written by Vitaliy). The Editorials can be found here.

Stacking Pancakes (written by Kaushik Iska). The Editorials can be found here.

Parallel Computing (written by Tomaz Hocevar). The Editorials can be found here.

PDS Number (written by Anh Duong Quang). The Editorials can be found here.

Fit to Play (written by Vamsi Kavala). The Editorials can be found here.

Similar Graphs (written by David Stolp). The Editorials can be found here

Substrings on a Tree (written by Sergey Kulik). The Editorials can be found here.

use memoization. save results

2★gargnitin123 @ 11 Apr 2012 06:58 PM
use memoization. save results 1000th number then keep returning answeres

@rajneesh2k10 yes you are

isha_adm @ 13 Apr 2012 10:31 PM
@rajneesh2k10 yes you are correct in saying that. There is no need for the extra 1ll in the product.

Take the case x=10^18, y=999;

isha_adm @ 14 Apr 2012 02:38 PM
Take the case x=10^18, y=999; Their lcm overflows and is positive when stored in signed long long. Product of 10^18 and 10^18 is negative because of many overflow cycles. Thus overflow depends on the input too and not just the limits of the input variables.

@ashmish2: no it is not, for

4★sourabh912 @ 15 Apr 2012 08:15 PM
@ashmish2: no it is not, for example for n=4 there are 15 possible combinations instead of 14 (1,1,1,1),(1,1,1,2),(1,1,2,1),(1,1,2,2),(1,1,2,3),(1,2,1,1),(1,2,1,2),(1,2,2,1),(1,2,2,2),1,2,2,3),(1,2,3,1),(1,2,3,2),(1,2,3,3),(1,2,3,4) and (1,2,1,3)

check out this link:

3★kq_viet @ 18 Apr 2012 12:17 PM
check out this link: http://www.codechef.com/node/1062815/revisions/1064751/view I dont know why @@.
Workden, MNR PRIDE, 14, HAL Old Airport Rd, Domlur I Stage, 1st Stage, DOMLUR, Bengaluru, Karnataka 560071 [email protected] +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

© 2025 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.