poj-2304

  • turn the dial clockwise 2 full turns 
  • stop at the first number of the combination 
  • turn the dial counter-clockwise 1 full turn 
  • continue turning counter-clockwise until the 2nd number is reached 
  • turn the dial clockwise again until the 3rd number is reached 
  • pull the shank and the lock will open.
#include<stdio.h>
int main()
{
	int n,first,midle,last,sum,t;
	while(scanf("%d%d%d%d",&n,&first,&midle,&last))
	{
		if(n==0 && first==0 && midle==0 && last==0)
			break;
		sum=1080;
		t=n-first;
		if(t<0)
			t+=40;
		sum+=t*9;
		t=midle-first;
		if(t<0)
			t+=40;
		sum+=t*9;
		t=midle-last;
		if(t<0)
			t+=40;
		sum+=t*9;
		printf("%d\n",sum);
	}
	return 0;
}

  

你可能感兴趣的:(poj-2304)