题意:给你n.m(n,m<=200),问你有多少条非水平.非垂直的直线有多少条经过至少两个点 题解:我们需要枚举的是只画一条线的矩形,对于大小a*b的矩形必须保证gcd(a,b)=1才能不重复 接着对于每个矩形可以放的位置有(n-a)(m-b)个,但是如果有矩形在某个矩形的左上方就会再次重复 因此只需要再减去max(0,n-2*a)*max(0,m-2*b)就好 import java.util.Scanner; public class Main{ static int Max=305; st…
Counting Triangles Problem Description Given an equilateral triangle with n thelength of its side, program to count how many triangles in it. Input The length n (n <= 500) of theequilateral triangle's side, one per line. process to the end of the fil…
Counting Triangles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2506 Accepted Submission(s): 1184 Problem Description Given an equilateral triangle with n the length of its side, program t…
1307 - Counting Triangles PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You are given N sticks having distinct lengths; you have to form some triangles using the sticks. A triangle is valid if its area is positive. You…
*注 虽然没什么人看我的博客但我还是要认认真真写给自己看 背包问题应用场景给定 n 种物品和一个背包.物品 i 的重量是 w i ,其价值为 v i ,背包的容量为C.应该如何选择装入背包中的物品,使得装入背包的总价值最大?*01 背包 *01 背包特点: 给定 n 种物品和一个背包 ( 每个物品只能选取一个).物品 i 的重量是w[i],其价值为v[i],背包的容量为C.应该如何选择装入背包中的物品,使得装入背包中的物品的总价值最大?*状态: dp[i][j] 表示在只能从 1-i 个物品中选…