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的更多相关文章

  1. sdut 2411:Pixel density(第三届山东省省赛原题,字符串处理)

    Pixel density Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Pixels per inch (PPI) or pi ...

  2. Android UI 设计:pixel dip dpi sp density

    1. px (pixels)像素 – 是像素,就是屏幕上实际的像素点单位. dip或dp (device independent pixels)设备独立像素,与设备屏幕有关. sp (scaled p ...

  3. 论文阅读笔记十九:PIXEL DECONVOLUTIONAL NETWORKS(CVPR2017)

    论文源址:https://arxiv.org/abs/1705.06820 tensorflow(github): https://github.com/HongyangGao/PixelDCN 基于 ...

  4. 字符串处理sdut 2411

    题目:http://www.sdutacm.org/sdutoj/problem.php?action=showproblem&problemid=2411 关于字符串处理的题,此题坑点很多w ...

  5. SDUT 2409:The Best Seat in ACM Contest

    The Best Seat in ACM Contest Time Limit: 1000MS Memory limit: 65536K 题目描述 Cainiao is a university st ...

  6. SDUT 2608:Alice and Bob

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Alice and Bob like playing ...

  7. SDUT 2623:The number of steps

    The number of steps Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Mary stands in a stra ...

  8. 浅谈响应式Web设计与实现思路

    是否还在为你的应用程序适配PC端,移动端,平板而苦苦思索呢,是否在寻找如何一套代码适配多终端方式呢,是否希望快速上手实现你的跨终端应用程序呢,是的话,那就看过来吧,本文阐述响应式UI设计相关理论基础, ...

  9. 一点响应式Web设计与实现思路

    摘要: 是否还在为你的应用程序适配PC端,移动端,平板而苦苦思索呢,是否在寻找如何一套代码适配多终端方式呢,是否希望快速上手实现你的跨终端应用程序呢,是的话,那就看过来吧,本文阐述响应式UI设计相关理 ...

随机推荐

  1. 误卸载python2.4导致yum不能用后的修复

    去 http://mirrors.ustc.edu.cn/centos/或者镜像下载如下包,版本不一定非常一致 python-2.4.3-56.el5.x86_64.rpmpython-devel-2 ...

  2. java.net.BindException: Address already in use: JVM_Bind

    是端口占用,如果修改端口后仍提示这样的错误,可能是eclipse自动关闭或正在运行服务非正常中断导致端口没有关闭,这时你再启动,还是提示java.net.BindException: Address  ...

  3. 11G中自动收集统计信息

    在11G中,引入了一个名为 gather_stats_prog 的自动运行任务专用于自动收集统计信息.其对应的客户端名称为"auto optimizer stats collection&q ...

  4. 汉字转【pinyin】

    引言 github地址:aizuyan/pinyin 无意中看到了overtrue/pinyin这个项目,感觉很有意思,这个项目做了这么一件事情: 将汉字转化为拼音 刚看到这里是不是觉得没什么难度,没 ...

  5. c++之路进阶——codevs4543(普通平衡树)

    4543 普通平衡树  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 大师 Master       题目描述 Description 这是一道水题 顺便祝愿LEZ和ZQQ 省 ...

  6. linux env

    .Linux的变量种类 按变量的生存周期来划分,Linux变量可分为两类: 1.1 永久的:需要修改配置文件,变量永久生效. 1.2 临时的:使用export命令声明即可,变量在关闭shell时失效. ...

  7. ansible自动化运维工具的安装与使用

    运行环境 centOS6.6 ansible ansible的功能还是比较多的,博主只用它在集群上进行批量部署软件和维护的功能,其他不多做研究,有需要的话这篇文章会慢慢补充. ansible特点 轻量 ...

  8. scan design rules

    为了更好的设计一个scan design,一些scan design的rule必须遵循. 1)tristate bus在shift mode下必须保持bus contention: 2)bidirec ...

  9. 解决vim无法返回上次的位置

    就是在vim的配置文件 ~/.vimrc 中添加一行这个: au BufReadPost * |if line("'\"") <= line("$&quo ...

  10. APP的UI测试要点

    1.文字显示是否正确 比如与需求图片对比是否正确,无错别字 2.对齐方式是否正确 3.图片 图片显示的篇幅不要太大. 4.颜色是否正确 颜色与需求规定的是否一致