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

×

ENIGMA08 - Editorial

PROBLEM LINK:

Sword in the game

Author and Editorialist : Sunny Karira

Difficulty

Medium

Pre-requisites

Dynamic Programming, Math

Problem

To find the damage done by golden sword and the damage will be calculated as the number of numbers on the slice of [1,N].

Quick Explanation

This problem can be solved using inclusion-exclusion principle.

Explanation

If fa1a2..ak(n) is the answer, then the following formula works:  fa1a2..ak(n) = fa2a3..ak(n) - fa2..ak(floor(n/a1))

But if you write only this recursive function, you get TLE.

The quickest approach was to solve the question using DP and memorize the answers for small n and all ai.

Solution:

Solution Link

This question is marked "community wiki".

asked 16 Oct '15, 22:17

sumit.asr_128's gravatar image

2★sumit.asr_128
464
accept rate: 10%

edited 16 Oct '15, 22:43

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:

×15,680
×2,595
×2,172
×877
×42

question asked: 16 Oct '15, 22:17

question was seen: 552 times

last updated: 16 Oct '15, 22:43