You are not logged in. Please login at www.codechef.com to post your questions!

×

alternative for nested loops in c

if there any alternative for nested loops to reduce execution time?

This question is marked "community wiki".

asked 08 Jun '14, 22:00

sparky007's gravatar image

3★sparky007
164511
accept rate: 0%


different Algorithm.

link

answered 08 Jun '14, 22:05

s1h33p's gravatar image

3★s1h33p
329239
accept rate: 15%

that is what i asked sir,

link

answered 08 Jun '14, 22:09

sparky007's gravatar image

3★sparky007
164511
accept rate: 0%

You can come up with different alternatives for different questions. For exempting loops, you need to think differently about the problem. A good approach would be:

  1. Write down the possible test cases (mainly boundary cases).
  2. Write down the outputs for them that you get by simply solving the problem mathematically.
  3. Try finding out a relation between the noted inputs and their corresponding outputs (there definitely is one alternative if you're getting TLE by naive approach).

Try this thing for the problem and you will hit a super simple relation between the inputs and outputs.

link
This answer is marked "community wiki".

answered 08 Jun '14, 22:47

xiaoyu_02's gravatar image

2★xiaoyu_02
5531923
accept rate: 5%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,491
×191

question asked: 08 Jun '14, 22:00

question was seen: 7,261 times

last updated: 08 Jun '14, 22:47