
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
History is littered with hundreds of conflicts over the future of a community, group, location or business that were "resolved" when one of the parties stepped ahead and destroyed what was there. With the original point of contention destroyed, the debates would fall to the wayside. Archive Team believes that by duplicated condemned data, the conversation and debate can continue, as well as the richness and insight gained by keeping the materials. Our projects have ranged in size from a single volunteer downloading the data to a small-but-critical site, to over 100 volunteers stepping forward to acquire terabytes of user-created data to save for future generations.
The main site for Archive Team is at archiveteam.org and contains up to the date information on various projects, manifestos, plans and walkthroughs.
This collection contains the output of many Archive Team projects, both ongoing and completed. Thanks to the generous providing of disk space by the Internet Archive, multi-terabyte datasets can be made available, as well as in use by the Wayback Machine, providing a path back to lost websites and work.
Our collection has grown to the point of having sub-collections for the type of data we acquire. If you are seeking to browse the contents of these collections, the Wayback Machine is the best first stop. Otherwise, you are free to dig into the stacks to see what you may find.
The Archive Team Panic Downloads are full pulldowns of currently extant websites, meant to serve as emergency backups for needed sites that are in danger of closing, or which will be missed dearly if suddenly lost due to hard drive crashes or server failures.
Imagine you have a special keyboard with the following keys:
Key 1: (A)
: Print one 'A' on screen.Key 2: (Ctrl-A)
: Select the whole screen.Key 3: (Ctrl-C)
: Copy selection to buffer.Key 4: (Ctrl-V)
: Print buffer on screen appending it after what has already been printed.Now, you can only press the keyboard for N times (with the above four keys), find out the maximum numbers of 'A' you can print on screen.
Example 1:
Example 2:
Note:
这道题给了我们四个操作,分别是打印A,全选,复制,粘贴。每个操作都算一个步骤,给了我们一个数字N,问我们N个操作最多能输出多个A。我们可以分析题目中的例子可以发现,N步最少都能打印N个A出来,因为我们可以每步都是打印A。那么能超过N的情况肯定就是使用了复制粘贴,这里由于全选和复制要占用两步,所以能增加A的个数的操作其实只有N-2步,那么我们如何确定打印几个A,剩下都是粘贴呢,其实是个trade off,A打印的太多或太少,都不会得到最大结果,所以打印A和粘贴的次数要接近,最简单的方法就是遍历所有的情况然后取最大值,打印A的次数在[1, N-3]之间,粘贴的次数为N-2-i,加上打印出的部分,就是N-1-i了,参见代码如下:
解法一:
这道题也可以用DP来做,我们用一个一维数组dp,其中dp[i]表示步骤总数为i时,能打印出的最多A的个数,初始化为N+1个,然后我们来想递推公式怎么求。对于dp[i]来说,求法其实跟上面的方法一样,还是要遍历所有打印A的个数,然后乘以粘贴的次数加1,用来更新dp[i],参见代码如下:
解法二:
这道题还有个O(1)时间复杂度的解法,好像利用了数学知识,不过博主貌似没太理解,参见这个帖子,哪位大神给博主讲解一下?
类似题目:
2 Keys Keyboard
参考资料:
https://discuss.leetcode.com/topic/97764/o-1-time-o-1-space-c-solution-possibly-shortest-and-fastest
https://discuss.leetcode.com/topic/97628/java-4-lines-recursion-with-step-by-step-explanation-to-derive-dp
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: