0

Help

#include <bits/stdc++.h> using namespace std; int main() { int n,m,g,j,a; cin>>n>>m>>g; if (g>=m) { cout<<-1; } else { j=m-g; n-=g; if (n%j==0) { a=n/j; cout<<a; } else { a=n/j+1; cout<<a; } } return 0; } What is missing from my code to accomplish this: 100 1 100 100 Another case would be this 80. 1 90 100 If I compile it, it gives me: - 1

28th Nov 2019, 12:48 PM
Israel Del Ángel
Israel Del Ángel - avatar
3 Answers
0
The problem is this: A snail climbs every day M centimeters along a wall that measures N centimeters. At nightfall, the snail falls asleep and slips G centimeters. You must create a program that tells you how many days the snail will take to climb the wall. Entry N - the length of the wall M- the number of centimeters the snail climbs each day G - the number of centimeters the snail slips during the night Departure The number of days the snail takes to climb to the upper edge of the wall. NOTE: in case the snail cannot reach the edge you must print -1
28th Nov 2019, 12:51 PM
Israel Del Ángel
Israel Del Ángel - avatar
0
Israel Del Ángel Kindly copy paste your code on the code playground and then share that link in your post.
28th Nov 2019, 1:01 PM
Avinesh
Avinesh - avatar
0
Israel Del Ángel Because in both the cases your g>=m is satisfied, so it prints -1.
28th Nov 2019, 3:33 PM
Avinesh
Avinesh - avatar