전체 글 (36) 썸네일형 리스트형 [Codility] Lesson12. CommonPrimeDivisors (C#) 문제: app.codility.com/programmers/lessons/12-euclidean_algorithm/common_prime_divisors/ CommonPrimeDivisors coding task - Learn to Code - Codility Check whether two numbers have the same prime divisors. app.codility.com int Z = A.Length; int result = 0; for (int i = 0; i < Z; i++) { if (isSameDivisors(A[i], B[i])) { result++; } } return result; static bool isSameDivisors(int a, int b) { int gcd_a.. [Codility] Lesson12. ChocolatesByNumbers (C#) 문제: app.codility.com/programmers/lessons/12-euclidean_algorithm/chocolates_by_numbers/ ChocolatesByNumbers coding task - Learn to Code - Codility There are N chocolates in a circle. Count the number of chocolates you will eat. app.codility.com if (N == 1) return 1; int gcd = getGCD(N, M); return N / gcd; static int getGCD(int N, int M) { if (M == 0) return N; return getGCD(M, N % M); } [Codility] Lesson11. CountSemiprimes (C#) 문제: app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_semiprimes/ CountSemiprimes coding task - Learn to Code - Codility Count the semiprime numbers in the given range [a..b] app.codility.com 아.. 문제 이해도 어렵다. int[] result = new int[P.Length]; int[] primeCheck = new int[N + 1]; int[] presum = new int[N + 1]; primeCheck[0] = 1; primeCheck[1] = 1; for (int i = 2; i * i [Codility] Lesson11. CountNonDivisible (C#) 문제: app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_non_divisible/ CountNonDivisible coding task - Learn to Code - Codility Calculate the number of elements of an array that are not divisors of each element. app.codility.com 결과: 66%.. 다시 풀자.. Dictionary listA = new Dictionary(); for (int i = 0; i < A.Length; i++) { if (!listA.ContainsKey(A[i])) { int count = 0; for (int j = 0.. [Codility] Lesson10. Peaks (C#) 문제: app.codility.com/programmers/lessons/10-prime_and_composite_numbers/peaks/ Peaks coding task - Learn to Code - Codility Divide an array into the maximum number of same-sized blocks, each of which should contain an index P such that A[P - 1] A[P + 1]. app.codility.com 우와... 45%.... 다시 풀어야 되네ㅠ if (A.Length < 3) return 0; int result = 0; for (int i = 1; i < A.Length - 1; i++) { if (A[i.. [Codility] Lesson10. MinPerimeterRectangle (C#) 문제: app.codility.com/programmers/lessons/10-prime_and_composite_numbers/min_perimeter_rectangle/ MinPerimeterRectangle coding task - Learn to Code - Codility Find the minimal perimeter of any rectangle whose area equals N. app.codility.com 결과: 70% 난 소수랑 안친한가 봄... if (N == 1) return 4; List perimeter = new List(); for (int i = 1; i [Codility] Lesson10. Flags (C#) 문제: app.codility.com/programmers/lessons/10-prime_and_composite_numbers/flags/ Flags coding task - Learn to Code - Codility Find the maximum number of flags that can be set on mountain peaks. app.codility.com 결과: 20% 뭐지 이건.. if (A.Length A[i - 1] && A[i] > A[i + 1]) { peek.Add(A[i]); } } if (peek.Count < 1.. [Codility] Lesson10. CountFactors (C#) 문제: app.codility.com/programmers/lessons/10-prime_and_composite_numbers/count_factors/ CountFactors coding task - Learn to Code - Codility Count factors of given number n. app.codility.com 결과: 71% 다시풀자... int count = 0; for (int i = 1; i 이전 1 2 3 4 5 다음