View Code of Problem 135

#include <stdio.h>
#include <string.h>
int main()
{
	int n;
	while(scanf("%d",&n) != EOF){
		int i,a[n];
		char str[n];
		getchar();
		for(i = 0;i < n;i++){
			scanf("%c%d",&str[i],&a[i]);
			getchar();
		}
		int x,y,x1,y1;
		x = y = 0;
		scanf("%d %d",&x1,&y1);
		for(i = 0;i < n;i ++){
			if(str[i] == 'L'){
				x -=a[i];
			}
			if(str[i] == 'R'){
				x +=a[i];
			}
			if(str[i] == 'F'){
				y +=a[i];
			}
			if(str[i] == 'B'){
				y -=a[i];
			}
		}
		if(x == x1&&y == y1){
			printf("MEME IS SO LUCKY\n");
		}
		else{
			printf("GPS ERROR\n");
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 135