2012山东省ACM省赛-Pixel density

Pixel
density


题目描述

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.

题目大意:字符串取数。如第一组测试数据,长:960,宽:640,求出对角线,除以3.5(inches)。

注意题目所说如果inches=0.0,输出0.00。


 1 #include<stdio.h>
2 #include<string.h>
3 #include<math.h>
4 char s[1001][101];
5 char str[101];
6
7 int main()
8 {
9 int n,i,k,m,len;
10 double a,b,inch,ans;
11 scanf("%d",&n);
12 getchar();
13 for(k=1;k<=n;k++)
14 {
15 inch=0.0;
16 for(i=0;;i++)
17 {
18 scanf("%s",s[i]);
19 if(strcmp(s[i],"inches")==0)//找到下手点
20 break;
21 }
22 m=i;
23 sscanf(s[m-1],"%lf",&inch);//把用字符串形式表示的浮点数,写入inch中
24 scanf("%lf*%lf",&a,&b);
25 gets(str);
26 len=strlen(str);
27 printf("Case %d: The ",k);
28 for(i=0;i<len;i++)
29 {
30 if(str[i]!=‘ ‘)//去掉前导空格
31 break;
32 }
33 for(;i<len;i++)
34 {
35 if(str[i]>=‘A‘&&str[i]<=‘Z‘)//这块很容易WA,可能输入的不止大写字母
36 printf("%c",str[i]-‘A‘+‘a‘);
37 else
38 printf("%c",str[i]);//比如是小写字母,就原样输出
39 }
40 printf(" of");
41 for(i=0;i<m-1;i++)
42 {
43 printf(" %s",s[i]);
44 }
45 printf("‘s PPI is ");
46 if(inch==0.0)
47 printf("0.00.\n");//别忘了题目所给条件
48 else
49 {
50 ans=(sqrt(a*a+b*b))/inch;
51 printf("%.2lf.\n",ans);
52 }
53 }
54 return 0;
55 }

时间: 2024-11-03 20:55:34

2012山东省ACM省赛-Pixel density的相关文章

[2012山东ACM省赛] n a^o7 !(模拟,字符替换)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst

[2012山东ACM省赛] Pick apples (贪心,全然背包,枚举)

Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描写叙述 Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because s

第十届山东省acm省赛补题(2)

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4124 L Median Time Limit: 1 Second      Memory Limit: 65536 KB Recall the definition of the median of  elements where  is odd: sort these elements and the median is the -th largest element.

[2012山东ACM省赛] Pick apples (贪心,完全背包,枚举)

Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描述 Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she

2017年山东省ACM省赛总结

----但求努力到问心无愧 这次比赛我们是作为友谊队去的,本来我们队选拔赛成绩并不是很好,是去不了的,但伟大的教主大人牛逼地又要到了几个省赛友谊队的名额,才让我们有这次见识大场面比赛的机会,在这里我们先要感谢教主,还有就是感谢陪同的老师们,还有一直忙里忙外的负责人学长和同学们. 然后就是检讨我们自己了.这次比赛我们真的打的很不好,虽然比赛方有好多地方弄得有点欠缺.首先是热身赛,开始我们以为会有好多题,发下题目来看原来只有3个,好有三个题就三个题,那就做,但是我们还没开始看题,就意识到一个问题:这

第七届山东省ACM省赛

激动人心的省赛终于结束了…平静下来再回头看真的感觉一波三折…先是赛前毫无预兆的查出突发性耳聋…伴随而来的就是左耳听力下降.轻微耳鸣.极个别情况下的头晕…不过这都还好,毕竟药物可以恢复…热身赛只过了一道输出济南有多少泉水的水题,竟然第二次就猜对了,有个队交了四五十次…山师很心机的把酒店安排在了商业区.闹市和女子学院附近…(开个玩笑)为了不败第二天人品,我老老实实地待在了酒店,并没有出去嗨…正式赛开了…比赛打得多了,真的不紧张了…或许是喝了磊神指定饮料-红牛的作用…A是个签到题,我和Julyc讨论一

第二届山东省ACM省赛回顾 Crack Mathmen(打表)

Crack Mathmen 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2165 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Since mathmen take security very seriously, they communicate in encrypted messages. They cipher

[2012山东ACM省赛] Fruit Ninja II (三重积分,椭球体积)

大概去年夏天的时候,在<C和指针>里面一个练习题要求实现一个很简单的不包含打印浮点数功能的printf函数.但是很好奇,于是一直纠结下去,结果就是知道了printf的实现,自己也写了一个简单的.或许是夏天的原因吧,那时候暑假没回去,凌晨四点兴奋到不能睡觉.那时候刚开始写blog.没想整理一下,只是简单的把最重要的实现"工具"贴了一个blog在 http://blog.csdn.net/cinmyheart/article/details/9804189 那时候第一次看lin

第十届山东省ACM省赛题解

点击跳转 A - Calandar H - Stones in the Bucket L - Median 原文地址:https://www.cnblogs.com/CSGOBESTGAMEEVER/p/10891007.html