原创 輸出凸包上的所有點

//從原點開始,按逆時針順序輸出凸包上的每個點 #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std;

原创 poj1157(簡單dp)

#include<iostream> #include<cstdio> #include<cstring> using namespace std; int f[105][105]; int a[105][105]; int main(

原创 百練2744

此題主要掌握常用的字符串處理函數:strlen: 計算字符串的長strncpy: 複製字符串的子串char* strncpy(char* dest, const char * src, size_t n );將source串的前n個字符複

原创 hdu2159(二維費用揹包)

//f[i][v][u]表示殺前i種怪,殺了v只,消耗了u忍耐度,得到的最大經驗值 #include<iostream> #include<cstdio> #include<cstring> using namespace std; i

原创 百練2746 約瑟夫問題

有n只猴子,從1開始報數,報到m的猴子離開,剩下的猴子接着從1開始報數。主要在於模擬整個過程。#include<stdio.h> int main() { int n,m; int a[301]; while(s

原创 百練2974

此題對重複電話號碼進行計數並對各電話號碼按照字典序升序輸出,採用map一舉兩得。#include<iostream> #include<stdio.h> #include<string.h> #include<map> #include<

原创 poj1657 Distance on Chessboard

本題關鍵在於分析棋盤上王、後、車、象的行走規則。設起點座標爲(x1,y1),終點座標爲(x2,y2);dx=abs(x1,x2),dy=abs(y1-y2)。1. 王可以橫、豎、斜走,每步一格所需最小步數爲min(dx,dy)+abs(d

原创 hdu5510(並查集+KMP)

/*題解:此題關鍵在超時,可用並查集來剪枝,把母串的子串都併到母串的集合裏 這樣的目的是查詢的時候直接找當前節點的父親,如果父親是該串的子串,則子串 必定也是,將父親標記爲已經訪問,不用再多次重複比較子串;如果父親不是該串 的子串,則直接

原创 poj2385

#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=1005; int f[1005][31]; int a[

原创 poj1787

//由於此題是要求恰好裝滿,故初始化時爲-OO #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define maxn 10005 #

原创 poj1952(dp+想法)

//此題難點在於求不能重複的種數 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int a[5002],f[5002],cnt[50

原创 poj1887(最長下降子序列)

#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define maxn 100000 int f[maxn]; int a[maxn]

原创 poj1276(多重揹包模板)

#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define maxn 100005 int n,v; int f[maxn]; in

原创 hdu2202

由於最大三角形總會由凸包的頂點圍成,故要先找到一個凸包,然後枚舉凸包的頂點#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using name

原创 poj2886(線段樹單點更新)

/*到1號節點的距離爲s的點,則該點的相對節點1的編號爲(s+n)%n+1,另外此題要打表求某個數的因子個數 反素數就是 對 x來說約束個數 G(x),如果 對於 i<x 有 G(i)<G(x) 則稱x爲反素數*/ #include<i