SDUT 2411:Pixel density

214人阅读 评论(0) 收藏 举报
分类:

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).

示例输入

2iPhone 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.

提示

来源

2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
typedef long long LL;
using namespace std;
int main()
{
    int T;
    cin>>T;
    string mess;
    char siz[1000];
    char x[1000];
    char y[1000];
    char name[1000];
    char type[1000];
    int sizp,xp,yp;
    int pos;
    int pos_t;
    double inch;
    int px,py;
    int cas=0;
    getchar();
    while(T--)
    {
        cas++;
        getline(cin,mess);
        pos=mess.find("inches");
        pos_t=pos-1;
        while(mess[pos_t]==' ') pos_t--;
        sizp=0;
        while(mess[pos_t]!=' ')
        {
            siz[sizp]=mess[pos_t];
            pos_t--;
            sizp++;
        }
        char tmp[1000];
        for(int i=0; i<=sizp; i++)
            tmp[sizp-i-1]=siz[i];
        tmp[sizp]='\0';
        sscanf(tmp,"%lf",&inch);
        while(mess[pos_t]==' ') pos_t--;
        for(int i=0; i<=pos_t; i++)
        {
            name[i]=mess[i];
        }
        name[pos_t+1]='\0';
        pos_t=pos+6;
        while(mess[pos_t]==' ') pos_t++;
        xp=0;
        while(mess[pos_t]!='*')
        {
            x[xp]=mess[pos_t];
            xp++;
            pos_t++;
        }
        x[xp]='\0';
        sscanf(x,"%d",&px);
        pos_t++;
        yp=0;
        while(mess[pos_t]!=' ')
        {
            y[yp]=mess[pos_t];
            yp++;
            pos_t++;
        }
        y[yp]='\0';
        sscanf(y,"%d",&py);
        while(mess[pos_t]==' ') pos_t++;
        for(int i=pos_t; i<mess.size(); i++)
        {
            if(mess[i]>='A'&&mess[i]<='Z')
                type[i-pos_t]=mess[i]+32;
            else type[i-pos_t]=mess[i];
        }
        type[mess.size()-pos_t]='\0';
        double ans;
        if(inch!=0)ans=sqrt(px*px+py*py)/inch;
        else ans=0.00;
        printf("Case %d: The %s of %s's PPI is %.2f.\n",cas,type,name,ans);
    }
    return 0;
}


查看评论

SDUT:2411 Pixel density

题意:给一句话,有屏幕尺寸和英寸,再输出一句话输出结果。 思路:数值好算,关键在于字符串处理。其实也不难,要好好利用库函数。注意0的特殊情况。 #include using namespace ...
  • kkkwjx
  • kkkwjx
  • 2015-04-13 08:04:15
  • 314

hdu Pixel density 2411

Pixel density  Time Limit: 1000MS Memory limit: 65536K  题目描述   Pixels per inch (PPI) or pixel ...
  • xiaoleiacm
  • xiaoleiacm
  • 2013-02-28 20:40:47
  • 410

SDUT 2411 Pixel density(模拟,字符串)

题目链接:SDUT 2411 Pixel density        这一题,可以说题目略坑。为什么呢,第一就是他题意描述过于模糊,第二题输出格式有点坑(说到底还是题意不要表述清晰)。现在我们来看看...
  • luomingjun12315
  • luomingjun12315
  • 2015-05-01 13:56:37
  • 898

关于android多分辨率中的density和density-independent pixel的区别

为何要引入dip?The reason for dip to exist is simple enough. Take for instance the T-Mobile G1. It has a p...
  • zhq56030207
  • zhq56030207
  • 2010-08-23 11:21:00
  • 3917

SDUT Pixel density

Pixel density Time Limit: 1000MS Memory limit: 65536K 题目描述 Pixels per inch (PPI) or pixe...
  • ACM2272902662
  • ACM2272902662
  • 2012-10-27 20:05:03
  • 600

Pixel density(简单的字符串处理)

1、题目大意: 给定字符串,处理,要求将其分成五个部分,很简单的题目,赛后一遍就对了,不过赛中却忽略了后几个空格的处理, Pixel density Time Limit: 1000MS ...
  • sdjzping
  • sdjzping
  • 2013-02-24 14:48:30
  • 879

SDUT 2411——Pixel density模拟细节WA了n遍

网址:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2411 山东省第三届ACM省赛的题。 注意...
  • sunbaofeng2
  • sunbaofeng2
  • 2013-04-10 16:22:15
  • 399

【模拟细节毕业题】SDUT 2411——Pixel density

来源:点击打开链接 山东省第三届ACM省赛的题。题不难,是个人就能读懂,但是WA的特别多,现场最多的队WA了26次,好多B题(亿级DP+贪心)改过了的队栽在了这个看似简单的模拟上。 注意点: 1...
  • mig_davidli
  • mig_davidli
  • 2013-02-26 16:21:59
  • 517

Sdut2411 Pixel density 山东省第三届ACM省赛(输入输出字符串处理)

本文出处:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&pr...
  • svitter
  • svitter
  • 2014-04-27 16:02:44
  • 1380

Android屏幕适配 px,dp,dpi及density的关系与深入理解

px(Pixel) : 既传统计算机语言中描述的像素,在Android则代表绝对像素。 之所以Android中不推荐使用这种单位,正是因为:Android中不同品牌,不同屏幕的设备,其分辨率亦不一。...
  • ghost_Programmer
  • ghost_Programmer
  • 2015-11-25 21:31:20
  • 3433
    个人资料
    专栏达人 持之以恒
    等级:
    访问量: 37万+
    积分: 1万+
    排名: 1992
    寻找 Qianqian 遇见 就是幸运
    博客专栏
    最新评论