Topic 1: Focus time limit:2000msSingle Point time limit:1000msMemory Limit:256MB
Descriptive narrative
Generally speaking. We use pinhole camera models. That is to say that it uses a small hole imaging principle.
In the camera coordinate system. In general, we use the unit length. Not the international unit of "M", but the length of neighboring pixels. The size of the focal length in the camera coordinate system is an important physical quantity in the field of image processing.
If we have been based on camera parameters. Get the physical focal length of the lens (focal length), and the width of the camera film (CCD width). and the horizontal resolution of the photo (image width), the detailed calculation formula is:
Focal length in pixels = (image width in pixels) * (Focal length to Earth)/(CCD width on earth)
For example, for Canon PowerShot S100, bringing in a formula
Focal length in pixels = pixels * 5.4mm/5.27mm = 1639.49 pixels
Now, write a common program to solve the size of the focal length in the camera coordinate system.
Input
Multiple sets of test data. The first is a positive integer t. The number of groups representing the test data.
One row for each set of test data, respectively
The physical focal length size of the lens (focal length on earth)
Width of camera film (CCD width on earth)
The horizontal resolution size (image width in pixels) of the photo, in PX.
separated by a space.
Output
Each set of data outputs a row in the format "casex:ypx".
X is the number of the test data. Start from 1. Y is the size of the focal length in the camera coordinate system (focallength in pixels), which retains 2 significant digits after the decimal point and rounds rounding.
Data range
For small data: focal length on earth and CCD width on earth units are all mm (mm)
For big data: Length units may also be meters (m), CM (DM), centimeters (cm), mm (mm), Micron (UM), nanometer (nm)
-
-
Example input
-
-
25.4mm 5.27mm 1600px5400um 0.00527m 1600px
-
-
Example output
-
Case 1:1639.47pxcase 2:1639.47PX
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include < string> #include <vector> #include <cmath>using namespace std;double Jinwei (string a) {int len=a.size (); Double h=0; if (a[len-2]== ' C ') {h=10; } else if (a[len-2]== ' d ') {h=100; } else if (a[len-2]== ' u ') {h=0.001; } else if (a[len-2]== ' n ') {h=0.000001; } else if (a[len-2]== ' m ' | | a[len-2]== ' P ') {h=1; } else {h=1000; } return h;} Double Change (String a) {char s[1010]; int k=0; Double H=jinwei (a); for (int i=0;i<a.size (), i++) {if (a[i]>= ' a ' &&a[i]<= ' z ') break; S[k++]=a[i]; } s[k]= ' + '; Double sum=0; Sum=atof (s); Sum*=h; return sum;} int main () {int t; while (cin>>t) {for (int k=1;k<=t;k++) {string a,b,c; cin>>a>>b>>c; DoUble V1,v2,v3; V1=change (a); V2=change (b); V3=change (c); cout<<v1<< "" <<v2<< "" <<v3<<endl; Double sum=v3*v1/v2; int s=sum*100+0.5; cout<< "Case" <<k<< ":"; printf ("%.2lfpx\n", (double) s/100); }} return 0;}
The water problem can be easily boiled down.
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
2014 Microsoft programming beauty heats first focus