Google Map
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2855
View Code
#include<stdio.h> #include<string.h> #include<math.h> double PI = acos(-1) ; double N = log(tan(PI/4 + (85*PI/180)/2)) ; double S = log(tan(PI/4 + (-85*PI/180)/2)) ; double W = -PI ; double E = PI ; double n, s, w, e ; double longitude, latitude ; int t ; void judge(double p, double q) { if(p>(w+e)/2) { w = (w+e)/2 ; if(q>(n+s)/2) { s = (s+n)/2 ; printf("r") ; } else { n = (n+s)/2 ; printf("s") ; } } else { e = (w+e)/2 ; if(q>(n+s)/2) { s = (s+n)/2 ; printf("q") ; } else { n = (n+s)/2 ; printf("t") ; } } } int main() { int i ; //freopen("a.txt","r",stdin) ; //freopen("b.txt","w",stdout) ; while(scanf("%lf%lf%d",&longitude,&latitude,&t)!=EOF) { n = N ; s = S; w = W; e = E ; double p = (longitude*PI)/180 ; double q = log(tan(PI/4 + (latitude*PI/180)/2)) ; printf("t") ; for(i=0; i<t; i++) { judge(p, q) ; } printf("\n") ; } return 0 ; }