zoukankan      html  css  js  c++  java
  • SDUT ACM 2411 Pixel density 字符串处理 Anti

     

    Pixel density

    Time Limit: 1000MS Memory limit: 65536K

    题目描述

    Pixels per inch (PPI) or pixel density is a measurement of the resolution of devices in various contexts; typically computer displays, image scanners, and digital camera image sensors. Note, the unit is not square inches. Good quality photographs usually require 300 pixels per inch when printed. When the PPI is more than 300(phone), we call it retina screen. Sunnypiggy like the retina screen very much.

    But you know it is expensive for Sunnypiggy and Sunnypiggy’s own smart phone isn’t like that.
    I tell you how to calculate the PPI. First we must know how big the mobile phone’s screen is. Then we get the resolution (Hp*Wp) about it. After that we calculate the diagonal resolution in pixels (Dp) and divided by diagonal size in inches. Now you get the answer.
    Maybe you knew it, but Sunnypiggy’s math is very bad and he wants you to help him to calculate the pixel density of all the electronic products he dreamed.
     

    输入

    First you will get an integer T which means the number of test cases, and then Sunnypiggy will tell you the name and type of the electronic products. And you know, Sunnypiggy is a careless boy and some data aren’t standard, just like 04.00 inches or 0800*0480.

    输出

    Output the answers to Sunnypiggy just like the sample output. Maybe it is not a phone. Sunnypiggy like such a form, although it seems no use. The result should be rounded to 2 decimal places. When it has no screen (0.0 inches) that we define the answer is 0.00(PPI).

    示例输入

    2
    iPhone 4S  3.5 inches 960*640 PHONE
    The new iPad  0009.7 inches 2048*1536 PAD
    

    示例输出

    Case 1: The phone of iPhone 4S's PPI is 329.65.
    Case 2: The pad of The new iPad's PPI is 263.92.
    

    提示

    Dp= sqrt(Wp*Wp+Hp*Hp )
    Wp is width resolution in pixels, Hp is height resolution in pixels.

    来源

    2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛
     
     
     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<math.h>
     4 char s[10010][1010];
     5 int main()
     6 {
     7     char c;
     8     int t, item, div, n;
     9     double wp, hp, inch, dp;
    10     scanf("%d", &t);
    11     for(item = 1; item <= t; item++)
    12     {
    13         for(n = 0; scanf("%s%c", s[n], &c); n++)
    14         {
    15             if(!strcmp(s[n], "inches"))div = n; //记录“inches”的下标
    16             if(c == '\n')break;
    17         }
    18         sscanf(s[div-1], "%lf", &inch); //屏幕尺寸
    19         sscanf(s[div+1], "%lf*%lf", &hp, &wp); //高度和宽度
    20         for(int i = 2; i <= n; i++)  //类型名大写换成小写
    21         {
    22             for(int j = 0; s[div+i][j]; j++)
    23                 if(s[div+i][j] >= 'A' && s[div+i][j] <= 'Z')
    24                     s[div+i][j] += 32;
    25         }
    26         dp = 10 * sqrt(hp/10*hp/10  + wp/10*wp/10); //避免乘法溢出,缩小了一点
    27         printf("Case %d: The", item);
    28         for(int i = div+2; i <= n; i++)
    29             printf(" %s", s[i]);
    30         printf(" of");
    31         for(int i = 0; i <= div-2; i++)
    32             printf(" %s", s[i]);
    33         printf("'s PPI is %.2lf.\n", inch <= 1e-9 ? 0.0 : dp/inch); //屏幕尺寸为0时输出0.00,当初没看清这个条件WA了几次。。
    34     }
    35     return 0;
    36 }
  • 相关阅读:
    考勤助手——基于CS三层结构的子系统设计
    淘宝网架构分析——反向代理
    软件架构风格——解释器风格详析
    软件架构风格
    考勤助手类图的设计
    任课教师管理考勤子系统之用例图
    考勤助手ER图2.0版本所存在的问题
    关于“考勤助手”体系架构风格的选取
    浅谈CDN技术的性能与优势
    软件体系结构——解释器风格的浅解
  • 原文地址:https://www.cnblogs.com/wolfred7464/p/3033011.html
Copyright © 2011-2022 走看看