Easy

n children have got m pieces of candy. They want to eat as much candy as they can, but each child must eat exactly the same amount of candy as any other child. Determine how many pieces of candy will be eaten by all the children together. Individual pieces of candy cannot be split.

Example

For n = 3 and m = 10, the output should be
candies(n, m) = 9.

Each child will eat 3 pieces. So the answer is 9.

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] integer n

    The number of children.

    Guaranteed constraints:
    1 ≤ n ≤ 10.

  • [input] integer m

    The number of pieces of candy.

    Guaranteed constraints:
    2 ≤ m ≤ 100.

  • [output] integer

    • The total number of pieces of candy the children will eat provided they eat as much as they can and all children eat the same amount.

[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 candies(int n,int m)
{
	return m-m%n;
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> Max Multiple  (0) 2020.04.07
<Codesignal> Seats in Theater  (0) 2020.04.07
<Codesignal> Largest Number  (0) 2020.04.07
<Codesignal> Add Two Digits  (0) 2020.04.07
<Codesignal> Sudoku  (0) 2020.04.06

+ Recent posts