poj 4006:小兔子捡金币
来源:互联网 发布:关闭135端口命令 编辑:程序博客网 时间:2024/04/25 22:58
螺旋矩阵
#include<iostream>#include<cmath>using namespace std;int main(){int m,n;cin>>m>>n;while(m--){int p,q,r;cin>>p>>q;r = min(p-1,q-1);r = min(r,n-p);r = min(r,n-q);int s = 0;int t = n - 2 * r;p = p - r;q = q - r;for(int i=1;i<=r;i++)s += 4 * (n - 1 - 2 * (i - 1));if(p == 1){cout<<s + q<<endl;continue;}if(q == t){s += t - 1;s += p;cout<<s<<endl;continue;}if(p == t){s += 2 * (t-1);s += t - q + 1;cout<<s<<endl;continue; }if(q == 1){s += 3 * (t - 1);s += t - p + 1;cout<<s<<endl;continue;}}return 0;}
0 0
- poj 4006:小兔子捡金币
- POJ 小兔子捡金币
- OpenJudge_P2987 小兔子捡金币
- [openjudge2987]小兔子捡金币
- 【OpenJudge 2987 】小兔子捡金币
- Openjudge 2987 小兔子捡金币
- 【OpenJudge 2987】小兔子捡金币
- openjudge 2787 小兔子捡金币 模拟
- OpenJudge noi 2987 小兔子捡金币(模拟)
- openjudge noi 2987 小兔子捡金币(模拟)
- 【OpenJ 2987】T3 小兔子捡金币(小金币捡兔子)
- 小兔子
- 小兔子故事集锦
- 古典小兔子问题
- POJ NOI0105-45 金币
- 捡金币
- 捡金币
- 大兔子和小兔子
- window下使用cmd执行php命令
- 键盘错位问题
- [Android]异步任务AsyncTask使用解析
- cocos2d-x,socket连接
- apache2.2.x和tomcat6.0.32集群并实现session复制功能
- poj 4006:小兔子捡金币
- for test code editer with js
- shu_1016 栈
- 找礼仪
- Android用摄像头的那点破事(续)
- Js中 关于top、clientTop、scrollTop、offsetTop的用法
- hibernate commit和flush
- this client is too old to work with working? SVN上遇到的这个问题的原因
- C++ 输出流迭代器