bnuoj 24251 Counting Pair
2015-10-21 12:36
453 查看
一道简单的规律题,画出二维表将数字分别相加可以发现很明显的对称性
题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=24251
题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=24251
#include<stdio.h> #include<string.h> #include<algorithm> #include<iostream> #include<math.h> using namespace std; int main() { int sum,n,m,Num,i,t; scanf("%d",&sum); for(i=1;i<=sum;i++) { scanf("%d %d",&n,&m); if(n>m) { int x=n; n=m; m=x; } scanf("%d",&t); printf("Case #%d:\n",i); while(t--) { scanf("%d",&Num); if(Num>n+m) printf("0\n"); else if(Num>n && Num>m) printf("%d\n",n+m-Num+1); else if(Num<=n && Num<=m) { if(Num == 0) printf("0\n"); else printf("%d\n",Num-1); } else if(Num>n && Num<=m) { printf("%d\n",n); } else if(Num==n && Num<=m) { printf("%d\n",n-1); } } } return 0; }
相关文章推荐
- 关于ByteArrayIO和DataIO的用法
- saiku - 访问saiku首页的时候前后台处理流程
- AFNetworkingErrorDomain 错误解决方法
- linker command failed with exit code 1 (use -v to see invocation)
- saiku - 系统登录成功后查询Cubes
- AIX查看CPU及内存参数
- 安卓跨应用调用Activity,Service并进行通信,AIDL的应用
- [Hadoop] - 异常Cannot obtain block length for LocatedBlock
- codeforces#323(div2) D. Once Again... 最长不下降子序列
- 解决SVN CONNOT VERIFY LOCK ON PATH NO MATCHING LOCK-TOKEN AVAILABLE
- adb remount 失败:remount failed: Operation not permitted问题解决
- 解密Airbnb的定价算法
- 遍历技巧:2,3,4sum&3sum closest&set matrix zeroes&Container With Most Water
- LeetCode OJ 11 Container With Most Water
- *LeetCode-Paint House
- 人工智能入门好帮手:Limia 550手机
- rsync: mkstemp ".test1.sh.ox5lBz" (in conf) failed: Permission denied (13)
- Eat Style --proposed by Chongyang Bai
- POJ 3421 X-factor Chains(构造)
- 内核线程&&系统调用exit&&wait4&&撤销进程