Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Chef and Weird Spider Editorial

$
0
0

Problem Link:https://www.codechef.com/EXCO2017/problems/EXOCODE6

Author:https://www.codechef.com/users/vivek96

DIFFICULTY:Easy

PREREQUISITES:Conditional statements and loops,Basic Programming

PROBLEM:Chef School of Witchcraft and Wizardry is known for moulding young minds into the finest wizards and witches. However that comes with a lot of practice. One of the young wizards cast a spell on a spider that makes it leap greater distances.

On observing closely the spider leaped 1 meter in its first leap. 10 meters in its second leap, 19 meters in its third leap , 28 meters in its fourth leap, 37 meters in its fifth leap and so on following a pattern.

In order to capture the spider, the young wizard must be able to tell the number of leaps the spider would take to reach a given distance.

EXPLANATION:It is clear that leap length is increased by 9 in every leap,So Now we have to count the minimum number of leaps required to a cover a distance >=N,so we count minimum no of leaps by using while(true) loop because we dont know the number of iterations exactly required to find minimum no of leaps.

Output must be in format: Case #1: (answer)

AUTHOR'S AND TESTER'S SOLUTIONS:

include<iostream>

alt text


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>