POJ1852-换向思考
作者:互联网
蚂蚁碰撞后反向与穿越的时间一样。
穷竭搜索---->想象力
#include<stdio.h> int main(void){ int n,len,ansNum,mintime,maxtime,loc; scanf("%d",&n); for(int i=1;i<=n;i++){ mintime=maxtime=0; scanf("%d %d",&len,&ansNum); for(int j=1;j<=ansNum;j++){ scanf("%d",&loc); if(loc<=len/2){ if(j==1){ mintime=loc; maxtime=len-loc; } else{ mintime=(mintime>=loc)?mintime:loc; maxtime=(maxtime>=len-loc)?maxtime:len-loc; } } else{ if(j==1){ mintime=len-loc; maxtime=loc; } else{ mintime=(mintime>=len-loc)?mintime:len-loc; maxtime=(maxtime>=loc)?maxtime:loc; } } } printf("%d %d\n",mintime,maxtime); } return 0; }
标签:loc,mintime,len,else,int,换向,思考,maxtime,POJ1852 来源: https://www.cnblogs.com/WhiteThornZzf/p/12435823.html