Contest Duration: - (local time) (100 minutes) Back to Home

Submission #927757

Source Code Expand

Copy
```import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author liymsheep
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
PrintWriter out = new PrintWriter(outputStream);
solver.solve(1, in, out);
out.close();
}

public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
long a = 1, b = 1;
for (int i = 0; i < n; ++i) {
long u = in.nextInt(), v = in.nextInt();
long g = BigInteger.valueOf(u).gcd(BigInteger.valueOf(v)).longValue();
u /= g;
v /= g;

long ratio = Math.max((a + u - 1) / u, (b + v - 1) / v);
a = u * ratio;
b = v * ratio;
}
out.print(a + b);
}

}

StringTokenizer tokenizer;

tokenizer = null;
}

public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
} catch (Exception e) {
throw new UnknownError();
}
}
}

public int nextInt() {
return Integer.parseInt(next());
}

}
}

```

#### Submission Info

Submission Time 2016-10-15 21:03:59+0900 C - AtCoDeer and Election Report littlesheep Java8 (OpenJDK 1.8.0) 300 2128 Byte AC 126 ms 9424 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
 AC × 3
 AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 102 ms 8788 KB
0_001.txt AC 99 ms 8528 KB
0_002.txt AC 98 ms 8528 KB
1_003.txt AC 98 ms 8528 KB
1_004.txt AC 126 ms 9296 KB
1_005.txt AC 102 ms 8656 KB
1_006.txt AC 120 ms 9040 KB
1_007.txt AC 106 ms 8784 KB
1_008.txt AC 101 ms 8656 KB
1_009.txt AC 99 ms 8532 KB
1_010.txt AC 100 ms 8656 KB
1_011.txt AC 100 ms 8528 KB
1_012.txt AC 100 ms 8656 KB
1_013.txt AC 126 ms 9424 KB
1_014.txt AC 119 ms 9420 KB