摘要:
题意:给出一些顶点均为整数坐标,问能构成多少个面积为整数的三角形。给出公式:A=|x1y2 - y1x2 + x2y3 - y2x3 + x3y1 - y3x1|/2分析:面积是否为整数只需要看|x1y2 - y1x2 + x2y3 - y2x3 + x3y1 - y3x1|mod2是否为0,所以可以先对每个x,y都mod2,并不影响结果。所以总共有4种点,01,00,10,11。3重循环枚举三角形的3个顶点分别是哪种,并用公式计算其面积是否为整数,若为整数则用组合数学知识,通过每种顶点的个数计算能构成的三角形数。View Code #include <iostream>#incl 阅读全文
posted @ 2011-08-14 22:55
undefined2024
阅读(242)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int n, size;void work(){ scanf("%d", &n); size = n * 2 + 1; for (int i = 0; i < size; i++) { printf("slice #%d:\n", i + 1); for (int j = 0; j &l 阅读全文
posted @ 2011-08-14 20:30
undefined2024
阅读(215)
评论(0)
推荐(0)

浙公网安备 33010602011771号