Пример #1
0
  private boolean buildNoteSequence() {

    noteSequence = new NoteSequence();

    double quantizeBeatFactor = quantizeBeatSetting * 1000.0 * 60.0 / (double) getBPM();
    double quantizeDurationFactor = quantizeDurationSetting * 1000.0 * 60.0 / (double) getBPM();

    for (int i = 0; i < noteList.size(); i++) {
      noteListElement = noteList.get(i);

      if (noteListElement.underTone == true) {
        continue;
      }

      note = noteListElement.note;

      if (note < getLowPitch()) continue;
      if (note > getHighPitch()) continue;

      double startTime = (double) (noteListElement.startTime);

      if (quantizeBeatFactor != 0.0)
        startTime = Math.floor(startTime / quantizeBeatFactor) * quantizeBeatFactor;
      long startTick = 1 + (long) (startTime * getTickRate() / 1000.0);

      double endTime = (double) (noteListElement.endTime);

      if (quantizeBeatFactor != 0.0)
        endTime = Math.ceil(endTime / quantizeBeatFactor) * quantizeBeatFactor;
      if (quantizeDurationFactor != 0)
        endTime =
            startTime
                + (Math.ceil((endTime - startTime) / quantizeDurationFactor)
                    * quantizeDurationFactor);

      long endTick = 1 + (long) (endTime * getTickRate() / 1000.0);

      if ((endTick - startTick) < 1) endTick = startTick + 1;
      System.out.println(
          "times: " + startTime + ", " + endTime + ", " + getStartTime() + ", " + getEndTime());
      if (endTime < getStartTime()) continue;
      if (startTime > getEndTime()) continue;

      velocity = 64;
      noteSequence.add(new NoteSequenceElement(note, ON, startTick, velocity));
      noteSequence.add(new NoteSequenceElement(note, OFF, endTick, velocity));
    }

    if (noteSequence.size() == 0) {
      return false;
    } else {
      noteSequence.sort();
      return true;
    }
  }
Пример #2
0
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String s = in.next();

    int l = s.length();
    Double sqrl = Math.sqrt(l);
    Double low = Math.floor(sqrl);
    Double high = Math.ceil(sqrl);
    int r = 0;
    int c = 0;

    if (low == high) {
      r = low.intValue();
      c = low.intValue();
    } else if (low * high >= l) {
      r = low.intValue();
      c = high.intValue();
    } else {
      r = high.intValue();
      c = high.intValue();
    }

    //        System.out.println("Row: " + r);
    //        System.out.println("Col: " + c);

    StringBuilder sb = new StringBuilder();
    char en[] = s.toCharArray();
    for (int i = 0; i < c; i++) {
      for (int j = 0; j < r; j++) {
        if (j * c + i < l) {
          sb.append(en[j * c + i]);
        }
      }
      sb.append(" ");
    }

    System.out.println(sb.toString());
  }
Пример #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();
    }
  }