设为首页 加入收藏

TOP

4452 模拟水题
2015-07-20 17:29:10 来源: 作者: 【 】 浏览:2
Tags:4452 模拟 水题
#include
  
   
#include
   
     #include
     
     using namespace std
     ; int abs
     (int a
     ) { return a
     >0
     ?a
     :(-a
     +1
     ); } int main() { int n
     ,i
     ,j
     ,s1
     ,t1
     ,s2
     ,t2
     ,m
     ; char first
     [5
     ],second
     [5
     ]; while(~scanf
     ("%d"
     ,&n
     ),n
     ) { scanf
     ("%s"
     ,first
     ); scanf
     ("%d%d"
     ,&s1
     ,&t1
     ); scanf
     ("%s%d%d"
     ,second
     ,&s2
     ,&t2
     ); scanf
     ("%d"
     ,&m
     ); int fx
     =1
     ,fy
     =1
     ,sx
     =n
     ,sy
     =n
     ; for(i
     =1
     ;i
     <=m
     ;i
     ++) { if(first
     [0
     ]=='W'
     ) { if(fy
     -1
     <s1
     ) { fy
     =s1
     -fy
     +2
     ; first
     [0
     ]='E'
     ; } else fy
     -=s1
     ; } else if(first
     [0
     ]=='E'
     ) { if(n
     -fy
     <s1
     ) { fy
     =2
     *n
     -s1
     -fy
     ; first
     [0
     ]='W'
     ; } else fy
     +=s1
     ; } else if(first
     [0
     ]=='N'
     ) { if(fx
     -1
     <s1
     ) { fx
     =s1
     -fx
     +2
     ; first
     [0
     ]='S'
     ; } else fx
     -=s1
     ; } else { if(n
     -fx
     <s1
     ) { fx
     =2
     *n
     -s1
     -fx
     ; first
     [0
     ]='N'
     ; } else fx
     +=s1
     ; } if(second
     [0
     ]=='W'
     ) { if(sy
     -1
     <s2
     ) { sy
     =s2
     -sy
     +2
     ; second
     [0
     ]='E'
     ; } else sy
     -=s2
     ; } else if(second
     [0
     ]=='E'
     ) { if(n
     -sy
     <s2
     ) { sy
     =2
     *n
     -s2
     -sy
     ; second
     [0
     ]='W'
     ; } else sy
     +=s2
     ; } else if(second
     [0
     ]=='N'
     ) { if(sx
     -1
     <s2
     ) { sx
     =s2
     -sx
     +2
     ; second
     [0
     ]='S'
     ; } else sx
     -=s2
     ; } else { if(n
     -sx
     <s2
     ) { sx
     =2
     *n
     -s2
     -sx
     ; second
     [0
     ]='N'
     ; } else sx
     +=s2
     ; } if(fx
     ==sx
     &&fy
     ==sy
     ) { char p
     =first
     [0
     ]; first
     [0
     ]=second
     [0
     ]; second
     [0
     ]=p
     ; } else { if(i
     %t1
     ==0
     ) { if(first
     [0
     ]=='W'
     ) first
     [0
     ]='S'
     ; else if(first
     [0
     ]=='E'
     ) first
     [0
     ]='N'
     ; else if(first
     [0
     ]=='N'
     ) first
     [0
     ]='W'
     ; else first
     [0
     ]='E'
     ; } if(i
     %t2
     ==0
     ) { if(second
     [0
     ]=='W'
     ) second
     [0
     ]='S'
     ; else if(second
     [0
     ]=='E'
     ) second
     [0
     ]='N'
     ; else if(second
     [0
     ]=='N'
     ) second
     [0
     ]='W'
     ; else second
     [0
     ]='E'
     ; } } } printf
     ("%d %d\n"
     ,fx
     ,fy
     ); printf
     ("%d %d\n"
     ,sx
     ,sy
     ); } return 0
     ; }
    
   
  
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 1505 City Game(01矩阵 dp) 下一篇HDU 1248 寒冰王座(dp)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)