Untitled
unknown
plain_text
4 years ago
2.1 kB
7
Indexable
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
class Result {
/*
* Complete the 'maxDias' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER N
* 2. INTEGER p
* 3. INTEGER q
* 4. INTEGER r
*/
public static int maxDias(int N, int p, int q, int r) {
int disponibles = 0;
for(int i = 0; i <= N; i++){
if((i%p == 0 && i%q != 0 && i%r != 0) || (i%p != 0 && i%q == 0 && i%r != 0) || (i%p != 0 && i%q == 0 && i%r == 0)){
disponibles++;
}
}
return disponibles;
}
}
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
int T = Integer.parseInt(bufferedReader.readLine().trim());
IntStream.range(0, T).forEach(TItr -> {
try {
String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
int dias = Integer.parseInt(firstMultipleInput[0]);
int A = Integer.parseInt(firstMultipleInput[1]);
int B = Integer.parseInt(firstMultipleInput[2]);
int C = Integer.parseInt(firstMultipleInput[3]);
int resultado = Result.maxDias(dias, A, B, C);
bufferedWriter.write(String.valueOf(resultado));
bufferedWriter.newLine();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
bufferedReader.close();
bufferedWriter.close();
}
}
Editor is loading...