Skip to content

Commit ac850f0

Browse files
committed
Add an SRM
1 parent e763c6d commit ac850f0

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

TopCoder/SRMs/SRM621/Div2_1000_MixingColors/MixingColors.java

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class FibonacciDiv2 {
2+
3+
public int find(int N) {
4+
int[] fib = new int[50];
5+
fib[0] = 0;
6+
fib[1] = 1;
7+
for (int i = 2; i < 50; i++)
8+
fib[i] = fib[i - 1] + fib[i - 2];
9+
int i = 0;
10+
for (i = 1; i < 50; i++)
11+
if (N <= fib[i] && N > fib[i - 1])
12+
break;
13+
return Math.min(fib[i] - N, N - fib[i - 1]);
14+
}
15+
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class BoxesDiv2 {
2+
3+
public int findSize(int[] candyCounts) {
4+
int sum = 0;
5+
for (int i = 0; i < candyCounts.length; i++) {
6+
sum += changetwices(candyCounts[i]);
7+
}
8+
return changetwices(sum);
9+
}
10+
11+
private int changetwices(int n) {
12+
int i = 1;
13+
while (i < n)
14+
i *= 2;
15+
return i;
16+
}
17+
}

0 commit comments

Comments
 (0)