UVA_12508 這個題目的一個坎就是要想到去枚舉三角形的外接矩形,如果想到這一點的話剩下的思路就不難想了,分情況計算出各種三角形(當然這些三角形的外接矩形必須是枚舉的這個矩形)的數量然後再乘以大矩形中有多少個這樣的外接矩形,這樣一種外接矩形的情況就算是算完了。所有外接矩形的情況累加起來就是最終的結果了。#include<stdio.h>#include<string.h>#include<algorithm>typedef long long LL;
POJ_1274 直接用匈牙利演算法求二分圖的最大匹配即可。#include<stdio.h>#include<string.h>#define MAXD 210int N, M, g[MAXD][MAXD], visy[MAXD], yM[MAXD];void init(){ int i, j, n, x; memset(g, 0, sizeof(g)); for(i = 1; i <= N; i ++) {
Connections in Galaxy WarTime Limit: 3 Seconds Memory Limit: 32768 KBIn order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began,
題目來源:POJ 1080 Human Gene Functionshttp://acm.pku.edu.cn/JudgeOnline/problem?id=1080 解法類型:動態規劃 解題思路: 網上一份解題報告:寫的很詳細,就此摘來:http://nash250.blog.hexun.com/9794371_d.html和《演算法導論》中動態規劃章節的LCS(Longest common subsequence
POJ_2989 求極大團的數量,我的程式是參照維基上的虛擬碼寫的http://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm。#include<stdio.h>#include<string.h>#define MAXN 130int N, M, a[MAXN], g[MAXN][MAXN];void input(){ memset(g, 0, sizeof(g)); for(int i =
Cube StackingTime Limit: 2000MS Memory Limit: 30000KTotal Submissions: 15900 Accepted: 5419Case Time Limit: 1000MSDescriptionFarmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with
Common SubstringsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 5495 Accepted: 1822DescriptionA substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two strings A, B and one integer K, we define S, a set of
EdgeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 886 Accepted Submission(s): 576Problem DescriptionFor products that are wrapped in small packings it is necessary that the sheet of paper