Example #1
0
  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));
  }
Example #2
0
  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++;
    }
  }
Example #3
0
  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();
    }
  }