Easy
Given a divisor and a bound, find the largest integer N such that:
- N is divisible by divisor.
- N is less than or equal to bound.
- N is greater than 0.
It is guaranteed that such a number exists.
Example
For divisor = 3 and bound = 10, the output should be
maxMultiple(divisor, bound) = 9.
The largest integer divisible by 3 and not larger than 10 is 9.
Input/Output
-
[execution time limit] 0.5 seconds (c)
-
[input] integer divisor
Guaranteed constraints:
2 ≤ divisor ≤ 10. -
[input] integer bound
Guaranteed constraints:
5 ≤ bound ≤ 100. -
[output] integer
- The largest integer not greater than bound that is divisible by divisor.
[C] Syntax Tips
// Prints help message to the console
// Returns a string
char * helloWorld(char * name) {
char * answer = malloc(strlen(name) + 8);
printf("This prints to the console when you Run Tests");
strcpy(answer, "Hello, ");
strcat(answer, name);
return answer;
}
더보기
Solution
int maxMultiple(int divisor,int bound)
{
return bound-bound%divisor;
}
728x90
'Codesignal' 카테고리의 다른 글
<Codesignal> Phone Call (0) | 2020.04.07 |
---|---|
<Codesignal> Late Ride (0) | 2020.04.07 |
<Codesignal> Seats in Theater (0) | 2020.04.07 |
<Codesignal> Candies (0) | 2020.04.07 |
<Codesignal> Largest Number (0) | 2020.04.07 |