본문 바로가기
728x90
반응형

codility25

[Codility] Lesson12 - Euclidean algorithm: Common Prime Divisors Problem A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integers are 2, 3, 5, 7, 11 and 13. A prime D is called a prime divisor of a positive integer P if there exists a positive integer K such that D * K = P. For example, 2 and 5 are prime divisors of 20. You are given two positive integers N and M. The goal is to check whether the sets of pr.. 2021. 2. 9.
[Codility] Lesson12 - euclidean algorithm: Chocolates By Numbers Problem Two positive integers N and M are given. Integer N represents the number of chocolates arranged in a circle, numbered from 0 to N − 1. You start to eat the chocolates. After eating a chocolate you leave only a wrapper. You begin with eating chocolate number 0. Then you omit the next M − 1 chocolates or wrappers on the circle, and eat the following one. More precisely, if you ate chocolat.. 2021. 2. 8.
[Codility] Lesson10 - Prime and composite numbers: MinPerimeterRectangle Problem n integer N is given, representing the area of some rectangle. The area of a rectangle whose sides are of length A and B is A * B, and the perimeter is 2 * (A + B). The goal is to find the minimal perimeter of any rectangle whose area equals N. The sides of this rectangle should be only integers. For example, given integer N = 30, rectangles of area 30 are: (1, 30), with a perimeter of 6.. 2021. 1. 30.
[Codility] Lesson10 - Prime and Composite numbers : CountFactors (c++) Problem A positive integer D is a factor of a positive integer N if there exists an integer M such that N = D * M. For example, 6 is a factor of 24, because M = 4 satisfies the above condition (24 = 6 * 4). Write a function: int solution(int N); that, given a positive integer N, returns the number of its factors. For example, given N = 24, the function should return 8, because 24 has 8 factors, .. 2021. 1. 12.
728x90
반응형