poj-2304
来源:互联网 发布:淘宝买二手ipad靠谱吗 编辑:程序博客网 时间:2024/05/21 12:08
- 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;}