这题目是小学奥数题目,方法可以百度到,但是,有个难点就是,数据类型大小不够,如果是1000x1000的矩阵,那么就会超过int的范围,所以,就引进了long long的数据类型 #include<stdio.h> int main(){ long long n,m,max; while(scanf("%lld %lld",&n,&m)!=EOF){ n=(n+1)*n/2; m=(m+1)*m/2; max=n*m; printf("%lld\n&…
题目链接 问题描述 一个棋盘有n条横线,m条竖线,上面有k个黑点,问有多少个不包含黑点的矩形. 数据范围: n和m最大为1000,k最大为10 方法一:动态规划 复杂度n*m*k. import java.awt.Point; import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class Main { int n, m;…
Description We are given a figure consisting of only horizontal and vertical line segments. Our goal is to count the number of all different rectangles formed by these segments. As an example, the number of rectangles in the Figures 1 and 2 are 5 and…