View Code of Problem 135

#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
	int m;
	while(scanf("%d",&m)!=EOF){
		int x=0,y=0,k;
		char a[1000];
		while(m--){
			scanf("%s",&a);
			int len=strlen(a);
			int s=0,l=0;
			for(k=len-1;k>=1;k++){
				s = s + (a[k]-'0')*pow(10,l++);
			}
			if(a[0]=='L'){
				x = x - s;
			}else if(a[0]=='R'){
				x = x + s;
			}else if(a[0]=='F'){
				y = y + s;
			}else if(a[0]=='B'){
				y = y - s;
			}
		}
		int i,j;
		scanf("%d %d",&i,&j);
		if(x==i&&y==j)
			printf("MEME IS SO LUCKY\n");
		else
			printf("GPS ERROR\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 135