Ejemplo n.º 1
0
  public void updateFile() {
    // writes highscore, coins and updates eveything else
    try {
      outFile = new PrintWriter(new BufferedWriter(new FileWriter("stats.txt")));
      outFile.println("" + (money + coins));
      outFile.println("" + powerUps.size());
      for (int i = 0; i < powerUps.size(); i++) {
        outFile.println("" + powerUps.get(i)); // writes the highscore in the file
      }
      outFile.println("" + chars.size());
      for (int i = 0; i < chars.size(); i++) {
        outFile.println("" + chars.get(i));
      }
      if (Integer.parseInt(stats.get(stats.size() - 3)) < score) {
        outFile.println(score);
      } else {
        outFile.println(stats.get(stats.size() - 3));
      }
      if (Integer.parseInt(stats.get(stats.size() - 2)) < score) {
        outFile.println(height);
      } else {
        outFile.println(stats.get(stats.size() - 2));
      }
      outFile.println(Integer.parseInt(stats.get(stats.size() - 1)) + height);

      outFile.close();
    } catch (IOException ex) {
      System.out.println("yooo stop noobing out");
    }
  }
Ejemplo n.º 2
0
  //    int frame = 0;
  public void paint(Graphics g) {
    // System.out.println("frame: " + (frame++));
    lStatus.setText(
        "t = "
            + df.format(md.dt * md.step)
            + ", "
            + "N = "
            + md.N
            + ", "
            + "E/N = "
            + df.format(md.E / md.N)
            + ", "
            + "U/N = "
            + df.format(md.U / md.N)
            + ", "
            + "K/N = "
            + df.format(md.K / md.N)
            + ", "
            + "p = "
            + df.format(md.p)
            + ";");
    tAvK.setText(df.format(md.avK.getAve() / md.N) + "  ");
    tAvU.setText(df.format(md.avU.getAve() / md.N) + "  ");
    tTemp.setText(df.format((2 * md.K) / (3 * (md.N - 1))) + "  ");
    tAvp.setText(df.format(md.avp.getAve()) + "  ");
    canvas.refresh(md.getXWrap(), md.N, true, false);
    cpnl.repaint();
    spnl.repaint();

    try {

      PrintWriter wavefunc =
          new PrintWriter(new FileOutputStream(new File("energyData.txt"), true));
      wavefunc.print(md.E / md.N + " " + md.K / md.N + " " + md.U / md.N);
      wavefunc.println();
      wavefunc.close();
    } catch (IOException ex) {
    }

    try {

      PrintWriter tempwriter =
          new PrintWriter(new FileOutputStream(new File("tempData.txt"), true));
      tempwriter.print(df.format((2 * md.K) / (3 * (md.N - 1))));
      tempwriter.println();
      tempwriter.close();
    } catch (IOException ex) {
    }
  }
Ejemplo n.º 3
0
  static void solve() throws IOException {
    String str;
    while ((str = br.readLine()) != null) {
      String[] s = str.split(",");
      int[] a = new int[10];
      int sum = 0;
      for (int i = 0; i < 10; i++) {
        a[i] = Integer.parseInt(s[i]);
        sum += a[i];
      }

      int v1 = Integer.parseInt(s[10]);
      int v2 = Integer.parseInt(s[11]);

      double r = (double) sum * v1 / (v1 + v2);

      sum = 0;
      for (int i = 0; i < 10; i++) {
        sum += a[i];
        if (r <= sum) {
          out.println((i + 1));
          break;
        }
      }
    }
  }
Ejemplo n.º 4
0
  static void solve() {
    int n = in.nextInt();
    int m = in.nextInt();
    boolean[] p = new boolean[m];
    for (int i = 0; i < n; i++) {
      int x = in.nextInt();
      for (int j = 0; j < x; j++) {
        p[in.nextInt() - 1] = true;
      }
    }

    for (int i = 0; i < m; i++) {
      if (!p[i]) {
        out.println("NO");
        return;
      }
    }

    out.println("YES");
  }
Ejemplo n.º 5
0
 static void solve() {
   String[] s = in.next().split(",");
   Point p =
       reflect(
           new Line(
               Double.parseDouble(s[0]),
               Double.parseDouble(s[1]),
               Double.parseDouble(s[2]),
               Double.parseDouble(s[3])),
           new Point(Double.parseDouble(s[4]), Double.parseDouble(s[5])));
   out.println(p.getX() + " " + p.getY());
 }
Ejemplo n.º 6
0
Archivo: A.java Proyecto: t8m8/AtCoder
  static void solve() {
    int r = in.nextInt();
    int c = in.nextInt();
    int sy = in.nextInt() - 1;
    int sx = in.nextInt() - 1;
    int gy = in.nextInt() - 1;
    int gx = in.nextInt() - 1;
    char[][] t = new char[r][c];
    for (int i = 0; i < r; i++) {
      t[i] = in.next().toCharArray();
    }

    ArrayDeque<int[]> que = new ArrayDeque<>();
    BitSet visited = new BitSet();

    que.add(new int[] {sy, sx, 0});
    visited.set(sy * c + sx);

    int[] dx = {0, 1, 0, -1};
    int[] dy = {1, 0, -1, 0};
    int[][] dist = new int[r][c];

    while (!que.isEmpty()) {
      int[] p = que.pollFirst();
      int cy = p[0];
      int cx = p[1];
      int d = p[2];
      dist[cy][cx] = d;

      for (int i = 0; i < 4; i++) {
        int ny = cy + dy[i];
        int nx = cx + dx[i];
        if (ny < 0 || nx < 0 || r <= ny || c <= nx) continue;
        if (visited.get(ny * c + nx) || t[ny][nx] == '#') continue;
        que.add(new int[] {ny, nx, d + 1});
        visited.set(ny * c + nx);
      }
    }

    out.println(dist[gy][gx]);
  }
Ejemplo n.º 7
0
 static void solve() {
   int n = in.nextInt();
   int m = in.nextInt();
   int t = in.nextInt();
   int[] a = new int[n];
   for (int i = 0; i < n; i++) {
     a[i] = in.nextInt();
   }
   boolean[] f = new boolean[t * 2];
   for (int i = 0; i < n; i++) {
     for (int j = a[i] - m; j < a[i] + m; j++) {
       f[j] = true;
     }
   }
   int ans = 0;
   for (int i = 0; i < t; i++) {
     if (!f[i]) ans++;
   }
   dump(f);
   out.println(ans);
 }
Ejemplo n.º 8
0
Archivo: B.java Proyecto: t8m8/AtCoder
 static void solve() {
   long n = in.nextLong();
   long m = in.nextLong();
   long p = in.nextLong();
   out.println(modPow(n, p, m));
 }