acm小柯的图表

小珂最近有一个麻烦,就是要统计一下指定区域中有几个方格被染黑了.表格的布局及表格各个位置的坐标如下所示.有三种操作命令,BLACK x,y,l 表示把以坐标(x,y)为左上角顶点,(x+l-1,y+l-1)为右下角顶点的矩形染黑。WHITE x,y,l 表示吧指定区域染白。TEST x,y,l 表示计算指定区域的黑块的个数。说明:如果 x,y,x+l-1 ,y+l-1超出图表的范围,就只计算图表内部的。输入第一行有一个整数n(0<n<100),表示有n条命令,随后的n行有n个指令。输出遇到TEST命令,把结果输出并换行。样例输入5 BLACK 1 1 2 BLACK 2 2 2 T...
默认分类 | 2012-03-12 15:34 | 阅读 946 次 | 评论 0 条

逆序数输出问题

One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this measure is 5, since D is greater than four letters to its right and E is greater than one letter to its right. ...
默认分类 | 2012-03-11 15:49 | 阅读 827 次 | 评论 0 条

今天刚写的

#include <stdio.h>int main(){ int m,a,b,c,d; while(scanf("%d",&amp;m)&amp;&amp;m!=0) { if(m>0&amp;&amp;m<=4) printf("%d\n",m); else { a=2; b=3; c=4; d=a+c; while(m-6>=0) { a=b; b=c; c=d; d=a+c; m--; } prin...
默认分类 | 2011-11-21 15:02 | 阅读 692 次 | 评论 0 条
文章分类
最新评论