示例#1
0
int main(void)
{
	int c, n, p, rideCapacity, runs;

	while (cin >> c >> n >> p)
	{
		if(c == 0 && c == n && n == p)
			break;

		rideCapacity = calcRideCapacity(c, n);
		runs = calcRuns(p, rideCapacity);

		cout << runs << endl;
	}


	return EXIT_SUCCESS;
}// End main
示例#2
0
static int
cacheTrim (tr_cache * cache)
{
  int err = 0;

  if (tr_ptrArraySize (&cache->blocks) > cache->max_blocks)
    {
      /* Amount of cache that should be removed by the flush. This influences how large
       * runs can grow as well as how often flushes will happen. */
      const int cacheCutoff = 1 + cache->max_blocks / 4;
      struct run_info * runs = tr_new (struct run_info, tr_ptrArraySize (&cache->blocks));
      int i=0, j=0;

      calcRuns (cache, runs);
      while (j < cacheCutoff)
        j += runs[i++].len;
      err = flushRuns (cache, runs, i);
      tr_free (runs);
    }

  return err;
}