Time Limit: 1 Second Memory Limit: 32768 KB
In this age of Internet, on-line connections, instantaneous email, etc., there are still some people who need to work with floppy disks. John is one of those. Every evening he goes home and continues what he has been doing in his office on his private UNIX system. He copies all the files he needs to floppy disks according to the following procedure:
1. Put all files in one big SHAR file.
2. Compress the file.
3. Uuencode it, such that it is split in nice lines of 62 characters each (including the new-line).
4. Split it in files of 30,000 lines each (about 1.86Mb).
5. Compress each of the files and put it on a floppy by itself.
So far, this procedure always worked, since 1.86Mb of uuencoded text, after compression, will nicely fit on a 1.44Mb floppy disk.
Now, given that through compression the size of the SHAR file halves and that uuencoding a compressed file adds 50% to its size (each rounded to the nearest integer number of bytes), we would like to know for a given size of the SHAR file how many floppies John needs.
Input Specification
The input contains several test cases. Each test case consists of a single line containing one integer s (0 <= s <= 1,000,000,000), specifying the size of the SHAR file in bytes.
The file ends with a file having s = 0. Do not generate output for this file.
Output Specification
For each test case, first output the number of the test case ('File #1', 'File #2', etc.), followed by a line that contains the minimal number of floppies needed for the transfer and a blank line. Adhere to the format shown below in the sample output.
Sample Input
1000000
10000000
100000000
0
Sample Output
File #1
John needs 1 floppies.
File #2
John needs 5 floppies.
File #3
John needs 41 floppies.
这个题目当时和同学看得纠结死了,结果当时题目还是不了解。看了别人的代码后又觉得0.75出现的不合情理。后来才发现,我们是纠结在1.86和1.44上了,换算来换算去还是得不到。最后发现二进制文件压缩成shar文件,变为half,再变成二进制文件又变为原来的50%。这样就得到了3/4.
整个题目的解释如下,代码不是原创的。
每天晚上john回家继续在他的UNIX系统上工作,他要用磁盘把文件装回家
1.把所有文件打包成一个SHAR文件
2.压缩这个SHAR文件
3.把二进制文件转换成文本文件,每行有62个字符(包括回车)
4.把转换后的文件分割成小份,每30,000行一份 (大约1.86M)
5.再压缩小文件,放进3.5软盘(floopy)里
这方法一定能行,因为1.86M的文件压缩后刚好能放进1.44M的软盘里
已知:
SHAR压缩后将会变成原大小的一半,
把二进制文件转换成文本会增加50%体积,
(计算后的结果四舍5入为整数)
我们需要知道john需要多少张软盘
code:
#include <stdio.h>
int main(){
int T=1;
double n;
while(scanf("%lf",&n)&&n)
printf("File #%d/nJohn needs %d floppies./n/n",T++,int(n*0.75/1860000+1));
return 0;
}