#include<iostream> #include<stdio.h> #include<string.h> #include<math.h> using namespace std; char str[12345]; char str1[12345]; char str2[12345]; char num1[12345]; char num2[12345]; char num3[12345]; int main(){ int T; int i; int len; int len1,len2; int p1,p2; int p3,p4; int len_num1,len_num2,len_num3; int j; double a,a1,a2,b,b1,b2,c,c1,c2; int p5; double Dp; double ans; int ca=0; int p6,p7; scanf("%d",&T); getchar(); //scanf("%[^\n]",str); //cout<<str<<endl; while(T--){ scanf("%[^\n]",str); getchar(); //printf(""); //printf("%s\n",str); //cout<<str<<endl; len=strlen(str); //cout<<len<<endl; len1=0; len2=0; len_num1=0; len_num2=0; len_num3=0; for(i=0;i<len;++i){ if(str[i]=='i'){ if(str[i+1]=='n'&&str[i+2]=='c'&&str[i+3]=='h'&& str[i+4]=='e'&&str[i+5]=='s'&&str[i+6]==' '){ p1=i; j=i-1; while(str[j]==' '){ --j; } while(str[j]!=' '){ num1[len_num1++]=str[j--]; } while(str[j]==' '){ --j; } p3=j; } } if(str[i]=='*'){ if(i>=1&&'0'<=str[i-1]&&str[i-1]<='9'){ if('0'<=str[i+1]&&str[i+1]<='9'){ p2=i; j=i-1; while(str[j]!=' '){ num2[len_num2++]=str[j--]; } j=i+1; while(str[j]!=' '){ num3[len_num3++]=str[j++]; } while(str[j]==' '){ ++j; } p4=j; } } } } for(i=0;i<=p3;++i){ if(str[i]!=' '){ break; } } str1[len1++]=str[i++]; for(;i<=p3;++i){ if(str[i]==' '&&str1[len1-1]==' '){ continue; } str1[len1++]=str[i]; } str1[len1]='\0'; for(i=p4;i<len;++i){ if(str[i]==' '&&str2[len2-1]==' '){ continue; } if('a'<=str[i]&&str[i]<='z'){ str2[len2++]=str[i]; } else if('A'<=str[i]&&str[i]<='Z'){ str2[len2++]=str[i]+32; } else{ str2[len2++]=str[i]; } } str2[len2]='\0'; for(i=len2-1;i>=0;--i){ if(str2[i]!=' '){ len2=i+1; break; } } str2[i+1]='\0'; /* cout<<str1<<endl; cout<<str2<<endl; cout<<num1<<endl; cout<<num2<<endl; cout<<num3<<endl; */ p5=-1; for(i=0;i<len_num1;++i){ if(num1[i]=='.'){ p5=i; break; } } a=0; a1=0; a2=0; if(p5==-1){ for(i=0;i<len_num1;++i){ a1=a1+(num1[i]-'0')*pow(10,i); } } else{ //a2=0; for(i=0;i<p5;++i){ a2=a2/10+(num1[i]-'0')/10.0; } //a1=0; for(i=p5+1;i<len_num1;++i){ a1=a1+(num1[i]-'0')*pow(10,(i-(p5+1))); } } //cout<<a2<<endl; //cout<<a1<<endl; a=a1+a2; //cout<<"a:"<<a<<endl; if(a==0){ printf("Case %d: The %s of %s's PPI is %.2f.\n",++ca,str2,str1,0.0); continue; } p6=-1; for(i=0;i<len_num2;++i){ if(num2[i]=='.'){ p6=i; break; } } if(p6==-1){ b=0; for(i=0;i<len_num2;++i){ b=b+(num2[i]-'0')*pow(10,i); } } else{ b=0; b1=0; b2=0; //cout<<p6<<"***"<<endl; for(i=0;i<p6;++i){ b2=b2/10+(num2[i]-'0')/10.0; //cout<<"##"<<b2<<endl; } for(i=p6+1;i<len_num2;++i){ b1=b1+(num2[i]-'0')*pow(10,(i-(p6+1))); } /* for(i=p5-1;i>=0;--i){ a2=a2/10+(num1[i]-'0')/10.0; } //a1=0; for(i=p5+1;i<len_num1;++i){ a1=a1+(num1[i]-'0')*pow(10,(i-(p5+1))); } */ b=b1+b2; //cout<<"b:"<<b<<endl; } p7=-1; for(i=0;i<len_num3;++i){ if(num3[i]=='.'){ p7=i; break; } } if(p7==-1){ c=0; for(i=0;i<len_num3;++i){ c=c*10+(num3[i]-'0'); } } else{ c=0; c1=0; c2=0; for(i=0;i<p7;++i){ //c2=c2/10+(num3[i]-'0')/10.0; c1=c1*10+(num3[i]-'0'); //cout<<"##"<<c2<<endl; } for(i=p7+1;i<len_num3;++i){ //c1=c1+(num3[i]-'0')*pow(10,(i-(p7+1))); c2=c2/10+(num3[i]-'0')/10.0; } c=c1+c2; //cout<<"c:"<<c<<endl; } //cout<<b<<endl; //cout<<c<<endl; Dp=sqrt(b*b+c*c); ans=Dp/a; //cout<<ans<<endl; printf("Case %d: The %s of %s's PPI is %.2f.\n",++ca,str2,str1,ans); } /* 33 ip 00300.00600 inches 00500.00600*00700.00800 IPHone 2 iPhone 4S 3.5 inches 960*640 PHONE The new iPad 0009.7 inches 2048*1536 PAD */ return 0; }