zoukankan      html  css  js  c++  java
  • HDU 4788 Hard Disk Drive (2013成都H,水题)

    Hard Disk Drive

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 83    Accepted Submission(s): 48


    Problem Description
      Yesterday your dear cousin Coach Pang gave you a new 100MB hard disk drive (HDD) as a gift because you will get married next year.
      But you turned on your computer and the operating system (OS) told you the HDD is about 95MB. The 5MB of space is missing. It is known that the HDD manufacturers have a different capacity measurement. The manufacturers think 1 “kilo” is 1000 but the OS thinks that is 1024. There are several descriptions of the size of an HDD. They are byte, kilobyte, megabyte, gigabyte, terabyte, petabyte, exabyte, zetabyte and yottabyte. Each one equals a “kilo” of the previous one. For example 1 gigabyte is 1 “kilo” megabytes.
      Now you know the size of a hard disk represented by manufacturers and you want to calculate the percentage of the “missing part”.
     
    Input
      The first line contains an integer T, which indicates the number of test cases.
      For each test case, there is one line contains a string in format “number[unit]” where number is a positive integer within [1, 1000] and unit is the description of size which could be “B”, “KB”, “MB”, “GB”, “TB”, “PB”, “EB”, “ZB”, “YB” in short respectively.
     
    Output
      For each test case, output one line “Case #x: y”, where x is the case number (starting from 1) and y is the percentage of the “missing part”. The answer should be rounded to two digits after the decimal point.
     
    Sample Input
    2 100[MB] 1[B]
     
    Sample Output
    Case #1: 4.63% Case #2: 0.00%
    Hint
     
    Source
     

    水题一枚。。。。胡搞就行

     1 /* ***********************************************
     2 Author        :kuangbin
     3 Created Time  :2013-11-16 12:58:01
     4 File Name     :E:2013ACM专题强化训练区域赛2013成都1008.cpp
     5 ************************************************ */
     6 
     7 #include <stdio.h>
     8 #include <string.h>
     9 #include <iostream>
    10 #include <algorithm>
    11 #include <vector>
    12 #include <queue>
    13 #include <set>
    14 #include <map>
    15 #include <string>
    16 #include <math.h>
    17 #include <stdlib.h>
    18 #include <time.h>
    19 using namespace std;
    20 
    21 int change(char s[])
    22 {
    23     if(strcmp(s,"B]") == 0)return 0;
    24     if(strcmp(s,"KB]") == 0)return 1;
    25     if(strcmp(s,"MB]") == 0)return 2;
    26     if(strcmp(s,"GB]") == 0)return 3;
    27     if(strcmp(s,"TB]") == 0)return 4;
    28     if(strcmp(s,"PB]") == 0)return 5;
    29     if(strcmp(s,"EB]") == 0)return 6;
    30     if(strcmp(s,"ZB]") == 0)return 7;
    31     if(strcmp(s,"YB]") == 0)return 8;
    32 }
    33 
    34 char s[100];
    35 int main()
    36 {
    37     //freopen("in.txt","r",stdin);
    38     //freopen("out.txt","w",stdout);
    39     int T;
    40     int iCase = 0;
    41     double a;
    42     scanf("%d",&T);
    43     while(T--)
    44     {
    45         iCase++;
    46         scanf("%lf[%s",&a,s);
    47         int t = change(s);
    48         double ans = pow(1000.0,t)/pow(1024.0,t);
    49         ans = 1-ans;
    50         printf("Case #%d: %.2lf%%
    ",iCase,ans*100);
    51 
    52 
    53     }
    54     return 0;
    55 }
  • 相关阅读:
    Redis-数据类型
    文件转二进制流拆分与组装
    word 文件转PDF 预览
    查询数据库还原时间
    Window10主机连接到Docker 中的mysql 数据库
    sqlServer 执行存储过程结果存表中
    启动mysql 镜像
    Java类型转换细节
    IDEA常用插件
    IDEA控制台中文乱码
  • 原文地址:https://www.cnblogs.com/kuangbin/p/3429034.html
Copyright © 2011-2022 走看看