fork download
  1. package RandomPractice;
  2.  
  3. import java.io.BufferedOutputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.PrintWriter;
  7. import java.util.InputMismatchException;
  8.  
  9. public class IdealRandomNumberGenerator {
  10. static int numChar;
  11. static int curChar;
  12. static byte[] buffer = new byte[1024];
  13. static InputStream stream;
  14. static PrintWriter out;
  15.  
  16. public static void main(String[] args) throws InputMismatchException, IOException {
  17. stream = System.in;
  18. StringBuilder builder = new StringBuilder();
  19. long a = readLong(), b = readLong(), c = readLong();
  20. long start = 0;
  21. long end = a + b;
  22. if (c <= end) {
  23. long g = gcd((c - start), (end - start));
  24. builder.append((c - start) / g + "/" + (end - start) / g + "\n");
  25. } else {
  26. builder.append("1/1\n");
  27. }
  28. out.print(builder);
  29. out.flush();
  30. out.close();
  31. }
  32.  
  33. public static long gcd(long a, long b) {
  34. if (b == 0)
  35. return a;
  36. return gcd(b, a % b);
  37. }
  38.  
  39. public static int read() throws IOException {
  40. if (numChar <= curChar) {
  41. curChar = 0;
  42. numChar = stream.read(buffer);
  43. if (numChar <= 0) {
  44. return -1;
  45. }
  46. }
  47. return buffer[curChar++];
  48. }
  49.  
  50. public static long readLong() throws IOException, InputMismatchException {
  51. int c = read();
  52. if (c == -1)
  53. throw new IOException();
  54. while (isSpaceChar(c)) {
  55. c = read();
  56. }
  57. boolean negative = false;
  58. if (c == '-') {
  59. negative = true;
  60. c = read();
  61. }
  62. long res = 0;
  63. while (!isSpaceChar(c)) {
  64. if (c < '0' || c > '9')
  65. throw new InputMismatchException();
  66. res *= 10;
  67. res += (c - '0');
  68. c = read();
  69. }
  70. if (negative)
  71. return -res;
  72. return res;
  73. }
  74.  
  75. public static int readInt() throws IOException, InputMismatchException {
  76. return (int) readLong();
  77. }
  78.  
  79. public static String readString() throws IOException {
  80. int c = read();
  81. if (c == -1)
  82. throw new IOException();
  83. while (isSpaceChar(c)) {
  84. c = read();
  85. }
  86. StringBuilder builder = new StringBuilder();
  87. while (!isSpaceChar(c)) {
  88. builder.append((char) c);
  89. c = read();
  90. }
  91. return builder.toString();
  92. }
  93.  
  94. public static boolean isSpaceChar(int c) {
  95. return c == ' ' || c == '\n' || c == '\t' || c == '\r' || c == -1;
  96. }
  97. }
  98.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: error: class IdealRandomNumberGenerator is public, should be declared in a file named IdealRandomNumberGenerator.java
public class IdealRandomNumberGenerator {
       ^
1 error
stdout
Standard output is empty