Submission #3768702
Source Code Expand
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); CMultipleClocks solver = new CMultipleClocks(); solver.solve(1, in, out); out.close(); } static class CMultipleClocks { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(); long[] arr = in.nextLongArray(n); long res = arr[0]; for (int i = 1; i < n; i++) { res = lcm(res, arr[i]); } out.println(res); } static long gcd(long a, long b) { a = Math.abs(a); b = Math.abs(b); while (b != 0) { long temp = a % b; a = b; b = temp; } return a; } static long lcm(long a, long b) { return b * (a / gcd(a, b)); } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) { return -1; } } return buf[curChar++]; } public int nextInt() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; ++i) array[i] = nextLong(); return array; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void close() { writer.close(); } public void println(long i) { writer.println(i); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Multiple Clocks |
User | rogernadal |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 4830 Byte |
Status | AC |
Exec Time | 76 ms |
Memory | 22740 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | sample_01.txt, sample_02.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 73 ms | 21332 KB |
sample_02.txt | AC | 74 ms | 21332 KB |
subtask_1_1.txt | AC | 74 ms | 18772 KB |
subtask_1_10.txt | AC | 76 ms | 18644 KB |
subtask_1_11.txt | AC | 74 ms | 21332 KB |
subtask_1_12.txt | AC | 75 ms | 20052 KB |
subtask_1_13.txt | AC | 74 ms | 19156 KB |
subtask_1_14.txt | AC | 73 ms | 17876 KB |
subtask_1_15.txt | AC | 74 ms | 20308 KB |
subtask_1_2.txt | AC | 75 ms | 20692 KB |
subtask_1_3.txt | AC | 71 ms | 18004 KB |
subtask_1_4.txt | AC | 74 ms | 18644 KB |
subtask_1_5.txt | AC | 73 ms | 22740 KB |
subtask_1_6.txt | AC | 73 ms | 18388 KB |
subtask_1_7.txt | AC | 73 ms | 17748 KB |
subtask_1_8.txt | AC | 74 ms | 18772 KB |
subtask_1_9.txt | AC | 74 ms | 18900 KB |