Time of Update: 2018-12-03
//4000多MS過的,資料應該比較大,還是比較簡單的#include <iostream>#include <cstdio>using namespace std;const int maxn = 1001;int n;float G[maxn][maxn];float Dist[maxn][maxn];int Q;int from,to;int main(){ while(cin>>n) {
Time of Update: 2018-12-03
#include <iostream>#include <string>#include <cstdio>using namespace std;int T;char str[1000];int begin,end;int main(){ while(scanf("%d",&T)!=EOF) { getchar(); for(int i = 1;i <= T; i++) {
Time of Update: 2018-12-03
做的很艱難,還參考了一下別人的。。。。。子問題是以每個矩形為底的塔的最大高度,所有子問題的解中最大的一個就是原問題的解,其中以某個矩形為底的塔的高度可以由自身高度加上可以放在其上的塔的最大高度得到#include <iostream>#include <algorithm>#include <cstring>using namespace std;int n;typedef struct{int xi;int yi;int zi;int base;
Time of Update: 2018-12-03
今天早上花了半個小時學了一下Emacs,瞬間我就想拋棄vim了Emacs命令參考 C-v 查看下一屏文字 M-v 查看上一屏文字 C-l 重繪螢幕,並將游標所在行置於螢幕的中央 游標定位命令 C-p 上一行 C-n 下一行 C-f 下一個字元 C-b 上一個字元 M-f 下一個單詞 M-b 上一個單詞 C-a 定位到行首 C-e 定位到行尾 M-a 定位到句首 M-e 定位到句尾 M-< 移動到文章開頭 M-> 移動到文章結尾 M-{ 向前移動一段 M-} 向後移動一段 M-g
Time of Update: 2018-12-03
動態規劃的有效性依賴於待求解問題本身具有兩個重要的性質:最優子結構性質和自問題重疊。(1)最優字結構性質,如果問題的最優解包含的自問題的解也是最優的,就稱該問題具有最優子結構性質(滿足最佳化原理),最優字結構性質為動態規划算法解決問題提供線索。(2)子問題重疊性質。子問題重疊性質是指在用遞迴演算法自頂向下對問題求解時,每次產生的子問題並不總是新問題,有些自問題會被重複計算多次。動態規劃正式利用了這種子問題的重疊性質,對每一個子問題只計算一次,然後將其計算結果儲存在一個表格中,當再次需要計算已經計
Time of Update: 2018-12-03
#include <iostream>#include <string.h>#include <cmath>#include <stdio.h>using namespace std;struct point{double x,y;};point p1,p2,p3;double a,h,l,k,b;double f (double x){return a*x*x*x/3 - (a*h + k/2)*x*x + (a*h*h+l-b)*x;}int
Time of Update: 2018-12-03
#include <iostream>#include <algorithm>using namespace std;struct ss{ int st; int ed;}node[110];//按電視節目結束時間排序 bool cmp(ss s1,ss s2){ return s1.ed < s2.ed || (s1.ed == s2.ed && s1.st < s2.st);}int main(){
Time of Update: 2018-12-03
//資料的分組與彙總GROUP BY 用於根據前面的的參數集分組結果SELECT _StateFORM MemberDetailsGROUP BY _State;SELECT _StateFROM MemberDetailsWHERE _State IN ('Mega state','Golden State','new State')GROUP BY _State;//可以基於多列分組SELECT _StateFROM MemberDetailsWHERE _State IN ('Mega
Time of Update: 2018-12-03
//這一題敲完直接AC,嚇尿了//kruskal做的,prim也行#include <iostream>#include <algorithm>#include <cstring>using namespace std;const int MAXN = 28;const int MAXM = 76;int T;struct edge{int u,v,w; }edges[MAXM];int Father[MAXN];int Rank[MAXN];int
Time of Update: 2018-12-03
--進階查詢的一些技巧--1.使用AND時,盡量將很可能不為真的條件放在前面--2.使用OR運算子時,盡量將最可能為真的條件放在前面--3.DISTINCT比ORDER BY更快SELECT MemberIdFROM OrdersGROUP BY MemberId;--SELECT DISTINCT MemberIdFROM Orders; --4.限制聯合的結果,從資料庫中提取的資訊越少,速度越快--5.對子查詢使用IN運算子WHERE MemberId = (SELECT MemberId
Time of Update: 2018-12-03
#include <stdio.h>#include <conio.h>int partition(int *R,int low,int high) //快速劃分{ int key; key=R[low]; while(low<high) { while(low<high&&R[high]>key) high--;
Time of Update: 2018-12-03
看了一些別人的題解,說實話,我現在還不會證明這個,我不知道為什麼這樣是最大值//hdu1003最大連續子序列和// sum[i] = sum[i-1]>0 ? sum[i-1]+a[i]:a[i];//只有當sum處於增長狀態時才會得到最大子序列//當sum處於減小狀態時,應當更新起點 #include <iostream>using namespace std;#define MAX 100003#define INF 0x7fffffff;int T;long N;int
Time of Update: 2018-12-03
轉載自http://tiger506.blog.51cto.com/318536/367624使用一段時間Fedora後會想聽聽mp3,意外發現預設的播放器竟然無法播放,別急,這篇博文閱畢此題可解。1.先安裝RPM Fusion(RPM Fusion提供Fedora 或 Red Hat下不提供的軟體,是一個第三方軟體褲),一定要先安裝。安裝方法:2.安裝播放器 Audacious (在安裝完RPM
Time of Update: 2018-12-03
DFS架構: vector<int> G[maxn]; int vis[maxn]; void dfs(int u) { vis[u] = 1; PREVISIT(u); int d = G[u].size(); for(int i = 0; i < d; i++) { int v = G[u][i];
Time of Update: 2018-12-03
基本思想:訪問頂點v0,然後訪問v0鄰接的未訪問過的頂點v1,再從v1出發遞迴的按照深度優先的方式遍曆。當遇到一個所有鄰接於它的頂點都被訪問過的頂點u時,則回到頂點序列中最後一個擁有未被訪問過的相鄰節點的頂點W,從W繼續出發。最終當任何已被訪問過的節點都沒有未被訪問的節點時,遍曆結束。bool visited[maxn]={0};void DFS(int x){ visited[x]=true; printf("%d\n",x); int i;
Time of Update: 2018-12-03
//sql基本語句整理//建立資料庫CREATE DATABASE database_name;//刪除資料庫DROP DATABASE database_name;//建立模式CREATE SCHEMA name_of_schema AUTHORIZATION name_of_user;//刪除模式DROP SCHEMA name_of_schema CASCADE; //連級刪除,包括所有對象DROP SCHEMA name_of_schema RESTRICT;
Time of Update: 2018-12-03
這個排序是演算法導論上堆排序的實現,#include<iostream>#include<time.h>using namespace std;void max_heap(int data[],int i,int len)//對於左右子樹已是最大堆的樹,將整個樹產生最大堆{int left=2*i+1; int right=left+1;int
Time of Update: 2018-12-03
#include <iostream>using namespace std;#define MAX 10001int N,M;int Father[MAX];int Rank[MAX];int sum;void Make_Set(int x){Father[x] = x;Rank[x] = 1;}int Find(int x){while(x != Father[x]){x = Father[x];}return x;}void Union(int x,int y){x =
Time of Update: 2018-12-03
//計算幾何+最小產生樹//注意精度//若兩單元園心距離小與半徑之和,則距離為0//反之,為距離-半徑之和#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>using namespace std;const int MAXN = 101;const int MAXM = 500000;int n;int M;double cost;double eps =
Time of Update: 2018-12-03
//貪心演算法//稍有點麻煩,要分析一下各種情況#include <iostream>#include <algorithm>using namespace std;int n;int Sp_A[1001];int Sp_B[1001];bool cmp(int x,int y){ return x > y;}int main(){ while(cin>>n) { if(n == 0)