码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 3809

时间:2014-12-16 06:28:40      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   ar   io   os   sp   for   java   

Decrypt coordinate

Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 703    Accepted Submission(s): 286


Problem Description
For national security, the coordinate systems of public map service are all in an encryption system. This means that when you got the latitude and longitude coordinates from a GPS device, you cannot finger out the real place at a public map with that coordinates.
We know an encryption system, which works as:
x1 = x – sqrt(y)
y1 = y – sqrt(x)
Now, we got some coordinates of POIs (point of interest, http://en.wikipedia.org/wiki/Point_of_interest, which you can just think as some points)
But even we have that formulations of how to encrypt coordinates, still we cannot decrypt any POI coordinate. Can you help us to decrypt all the POI coordinates?
 

 

Input
The first line contains a single integer T, indicating the number of test cases.
Each test case consists of two float number(x, y) in a single line.

Technical Specification

1. 1 <= T <= 10000
2. 0 <= x, y <= 10000
 

 

Output
For each test case, output the case number first, then the decrypted coordinates with six decimal digits.
If multiply answer exists, output the one which has minimal x.
 

 

Sample Input
4 500.116 5000 0 0 10000 10000 5000 5000
 

 

Sample Output
Case 1: 570.995444 5023.895511 Case 2: 0.000000 0.000000 Case 3: 10100.501250 10100.501250 Case 4: 5071.212446 5071.212446
 

 

Author
momodi@WHU
 

 

Source
 
迭代法
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<set>
using namespace std;
int t;
double x1,y11,x,y;
int main()
{
      int ca=1;
      scanf("%d",&t);
      while(t--)
      {
            scanf("%lf%lf",&x1,&y11);
            x=x1,y=y11;
            for(int i=0;i<45;i++)
            {
                  x=x1+sqrt(y);
                  y=y11+sqrt(x);
            }
            printf("Case %d: ",ca),ca++;
            printf("%.6lf %.6lf\n",x,y);
      }
      return 0;
}

  

 

hdu 3809

标签:des   blog   http   ar   io   os   sp   for   java   

原文地址:http://www.cnblogs.com/a972290869/p/4166254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!