摘要:
題目:http://acm.hdu.edu.cn/showproblem.php?pid=1496這個方法好快哦。View Code #include "iostream"#include "string"using namespace std;#define MAX 40000typedef struct hash{ int key; //乘積 int num; //乘積個數}hash;hash h[MAX];int Line(int k){ //線性探查法 int d = k%MAX; if(d<0){ d+=MAX; } while(h[..
閱讀全文
摘要:
題目:http://acm.swust.edu.cn/oj/problem/848/代碼:View Code #include "stdio.h"#include "string.h"#include "stdlib.h"#include "math.h"#include "iostream"#include "ctime"using namespace std;typedef struct node{ double x, y;}node;double Cal_Area(no
閱讀全文
摘要:
輸入uptime就可以了。顯示的內容依次為:現在系統時間/系統運行了多長時間/目前有多少個用戶/系統在過去的1分鐘,5分鐘,15分鐘的平均負載。
閱讀全文
摘要:
使用free -g 以G為單位free -m 以M為單位free -b 以B為單位來查看內存的使用情況。
閱讀全文
摘要:
1.使用man命令可以找到特定的聯機幫助面,并白日提供簡短的命令說明。使用man命令的語法格式為:man command_name比如我們要查看shutdown命令的詳細信息。應該這樣輸入man shutdown2.使用info在一定的情況下也是可以的。用法和man一樣。
閱讀全文
摘要:
題目:http://acm.hdu.edu.cn/showproblem.php?pid=2577用動態規劃角。on[i]表示在lock為開的時候輸入第i個字符時的最小按鍵次數。off[i]表示在lock為關的時候輸入第i個字符時的最小按鍵次數。View Code #include "iostream"#include "string"using namespace std;#define MAX 105int on[MAX], off[MAX];int main(){ int n; string str; cin>>n; while(n--
閱讀全文
摘要:
題目:http://acm.swust.edu.cn/oj/problem/324/View Code //1.動態范圍//2.動態次數//3.動態規律//4.動態邊界#include <stdio.h>#include<string.h>int main(){ int Live, Stand, Step; int f[101][2]; while(scanf("%d%d%d", &Live, &Step, &Stand)!=EOF){ memset(f, 0, sizeof(f)); f[Stand][0] = 1; int
閱讀全文
摘要:
滾動數組的作用在于優化空間,主要用在遞推和動態規劃中。因為dp題目是一個自底向上擴展過程,我們常常需要用到的是連續的解,前面的解往往可以舍去。所以用滾動數組優化是很有效的。利用滾動數組的話在N很大的情況下可以達到壓縮存儲的作用。滾動數組實際是一種節省空間的辦法,時間上沒啥優勢,多用于dp.其實用一維的數組來進行的簡單背包就是用了滾動數組啊。
閱讀全文
摘要:
今天做了一個簡單的題目。但是,我發現,在傳參數的時候,如果不使用引用傳參,那么頭指針就會隨著tmp指針向后移動。如果使用引用傳參的話,它就不會了。題目:http://acm.swust.edu.cn/oj/problem/172/View Code #include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct node{ int n; struct node *next;}node;node *A, *B, *ta, *tb, *p;void Init_AB(){ A = (node*
閱讀全文