this is more of a cp question than java, im doing a codeforce question that happens to be a part of an a2oj ladder im working my way through. this question says that there is 2 possible outputs for a certain input, but for some reason when i output any number besides the example, its wrong.
this is a link to the problem:
https://codeforces.com/problemset/problem/272/A
for the 1st and 3rd test my code does return 3 but for the 2nd test my code returns a 4 which should be acceptable if you look at the Note section at the bottom of the page. here is my code in java:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Fingers {
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int people = Integer.parseInt(input.readLine())+1, fCount = 0;
StringTokenizer fingers = new StringTokenizer(input.readLine());
for (int i = 0; i < people-1; i++) {
fCount += Integer.parseInt(fingers.nextToken());
}
int dividend = fCount%people;
if (dividend == 0) {
System.out.println(fCount/people+1);
} else {
System.out.println(people+2-dividend);
}
}
}
i accept all criticisms (bad practice, incorrect algorithms, missed opportunities) as i am still getting into competitive programming.