hiho week 125 register

Ended

Participants:153

Verdict:Accepted
Score:100 / 100
Submitted:2016-11-24 15:35:02

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
char Base32[]=
{
    '0','1','2','3','4','5','6','7','8','9','b','c','d','e','f','g','h','j','k','m','n','p','q','r','s','t','u','v','w','x','y','z'
};
string encode(double latt,double lonn,int precision)
{
    double lat[]= {-90,90};
    double lon[]= {-180,180};
    int len =precision*5;
    string geohash;
    int bits=0;
    for(int i=1; i<=len; i++)
    {
        if (i&1)
        {
            double mid=(lon[0]+lon[1])/2;
            if (lonn>mid)
                bits=bits<<1|1,lon[0]=mid;
            else
                bits<<=1,lon[1]=mid;
        }
        else
        {
            double mid=(lat[0]+lat[1])/2;
            if (latt>mid)
                bits=bits<<1|1,lat[0]=mid;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX