编程介的小学生 2019-09-14 21:58 采纳率: 20.5%
浏览 201

操作系统之问题,Operating system

Problem Description
As a CS student, operating system is an important lesson. Today, let’s think about the cache’s working mode. All object accesses go through the cache, so every time an object is accessed, it must be inserted into the cache if it was not already there. If the cache is full, you must take out a object which is already in the cache . All objects are of equal size, and no writes occur in the system, so a cached object is always valid. When the system starts, the cache is empty. To make cache works efficiently, we need find the optimal replacement algorithm. Optimality here means minimizing the number of times an object is read into the cache.

Input
There are several test cases in the input.

Each test case begins with three integers(C,N,B), separated by single spaces, telling you how many objects fit in the cache, 0 < C ≤ 10000, how many different objects are in the system, C ≤ N ≤ 100000, and how many accesses, 0 ≤ B ≤ 100000, will occur. The following line contains B integers between 0 and N-1 (inclusive) indicating what object is accessed.

Output
For each test case, output one integer, indicating the least number of times an object must be read into the cache to handle the accesses.

Sample Input
1 2 3
0 1 0
2 2 3
0 1 0

Sample Output
3
2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败
    • ¥15 MapReduce实现倒排索引失败
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码
    • ¥50 随机森林与房贷信用风险模型