public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scan = new Scanner(System.in); BigInteger bigInteger1 = scan.nextBigInteger(); BigInteger bigInteger2 = scan.nextBigInteger(); System.out.println(bigInteger1.add(bigInteger2)); System.out.println(bigInteger1.multiply(bigInteger2)); }
public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextBigInteger()) { BigInteger N = in.nextBigInteger(); if (N.compareTo(BigInteger.ONE) > 0) { BigInteger two = new BigInteger("2"); N = N.multiply(two).subtract(two); } System.out.println(N); } }
public static void main(String args[]) { Scanner cin = new Scanner(System.in); BigInteger a = BigInteger.ONE; int cas = 0; while (true) { cas++; a = cin.nextBigInteger(); if (a.compareTo(BigInteger.ZERO) == 0) break; long ans = calc(a); System.out.println("Case " + cas + ": Public Key = " + a + " Private Key = " + ans); } }
public static void main(String args[]) { Scanner in = new Scanner(System.in); int T; BigInteger sum = new BigInteger("0"); BigInteger aux = new BigInteger("0"); T = in.nextInt(); for (int i = 0; i < T; i++) { aux = in.nextBigInteger(); sum = sum.add(aux); } System.out.println(sum); }
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); boolean blank = false; while (scanner.hasNextBigInteger()) { if (blank) { System.out.println(); } else { blank = true; } BigInteger a = scanner.nextBigInteger(); BigInteger b = scanner.nextBigInteger(); System.out.println(a.gcd(b)); } }
public static void main(final String[] args) { final Scanner sis = new Scanner(System.in); output(HELP_MESSAGE); while (sis.hasNext()) { if (sis.hasNextInt()) { final int next = sis.nextInt(); output("You entered an Integer = %d", next); } else if (sis.hasNextLong()) { final long next = sis.nextLong(); output("You entered a Long = %d", next); } else if (sis.hasNextDouble()) { final double next = sis.nextDouble(); output("You entered a Double = %f", next); } else if (sis.hasNext("\\d+")) { final BigInteger next = sis.nextBigInteger(); output("You entered a BigInteger = %s", next); } else if (sis.hasNextBoolean()) { final boolean next = sis.nextBoolean(); output("You entered a Boolean representation = %s", next); } else if (sis.hasNext(DATE_PATTERN)) { final String next = sis.next(DATE_PATTERN); output("You entered a Date representation = %s", next); } else // unclassified { final String next = sis.next(); if (isValidURL(next)) { output("You entered a valid URL = %s", next); } else { if (EXIT_COMMANDS.contains(next)) { output("Exit command %s issued, exiting!", next); break; } else if (HELP_COMMANDS.contains(next)) { output(HELP_MESSAGE); } else { output("You entered an unclassified String = %s", next); } } } } /* This will close the underlying Readable, in this case System.in, and free those resources. You will not be to read from System.in anymore after this you call .close(). If you wanted to use System.in for something else, then don't close the Scanner. */ sis.close(); System.exit(0); }
public static void main(String[] args) { PrintWriter pw; Scanner sc; try { sc = new Scanner(new File("input.txt")); BigInteger a, b, c; a = sc.nextBigInteger(); b = sc.nextBigInteger(); c = a.divide(b); // System.out.println(firstTeam+" "+secondTeam); pw = new PrintWriter(new File("output.txt")); pw.print(c); pw.close(); } catch (IOException e) { } }
public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(new BufferedInputStream(System.in)); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = 1; while (scanner.hasNextInt()) { int a = scanner.nextInt(); int b = scanner.nextInt(); if (a == 0) break; BigInteger sum = BigInteger.ZERO; BigInteger bb = BigInteger.valueOf(b); for (int i = 0; i < a; i++) sum = sum.add(scanner.nextBigInteger()); System.out.println( "Bill #" + n + " costs " + sum + ": each friend should pay " + sum.divide(bb) + "\n"); n++; } }
public static void main(String args[]) { int t; Scanner s = new Scanner(System.in); t = s.nextInt(); BigInteger b1 = new BigInteger("0"); int b2; BigInteger b3 = new BigInteger("0"); BigInteger b4 = new BigInteger("10"); while (t > 0) { b1 = s.nextBigInteger(); b2 = s.nextInt(); b3 = b1.pow(b2); System.out.println(b3.mod(b4)); t--; } s.close(); }
public static void main(String[] args) { Scanner in = new Scanner(System.in); int row = in.nextInt(); int col = in.nextInt(); BigInteger r = in.nextBigInteger(); // System.out.println(row); // System.out.println(col); // System.out.println(r); int m[][] = new int[row][col]; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { m[i][j] = in.nextInt(); } } // for (int i = 0; i < row; i++) { // for (int j = 0; j < col; j++) { // System.out.print(m[i][j]); // } // System.out.println(); // } // System.out.println(Math.ceil(Math.sqrt(col))); for (int n = 0; n < Math.ceil(Math.sqrt(col)); n++) { int max_row = row - n; int max_col = col - n; // System.out.println("New array size: " + size); List<Integer> a = new ArrayList<Integer>(); for (int i = n; i < max_row - 1; i++) { a.add(m[i][n]); } // for (int i : a) { // System.out.print(i); // } // System.out.println(); for (int i = n; i < max_col - 1; i++) { a.add(m[max_row - 1][i]); } // for (int i : a) { // System.out.print(i); // } // System.out.println(); for (int i = max_row - 1; i > n; i--) { a.add(m[i][max_col - 1]); } // for (int i : a) { // System.out.print(i); // } // System.out.println(); for (int i = max_col - 1; i > n; i--) { a.add(m[n][i]); } // for (int i : a) { // System.out.print(i); // } // System.out.println(); if (n == max_row - 1) { for (int i = n; i < max_col - n; i++) { a.add(m[n][i]); } } for (int i : a) { System.out.print(i); } System.out.println(); } }