编程介的小学生 2019-12-31 22:10 采纳率: 20.5%
浏览 87

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 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用