#
schindlerlee原創(chuàng),禁止轉(zhuǎn)載和用于商業(yè)用途
邊看 見過大爺 邊寫竟然5分鐘不到秒了~
拓?fù)渑判蛴袃煞N做法,一種是不斷找入度為0的點(diǎn),然后刪點(diǎn)和關(guān)聯(lián)的邊,一種是利用dfs退棧的順序
如下:
1 /*
2 * SOUR:pku 2367
3 * ALGO:top sort
4 * DATE: Mon, 12 Oct 2009 00:56:07 +0800
5 * COMM:2
6 * */
7 #include<iostream>
8 #include<cstdio>
9 #include<cstdlib>
10 #include<cstring>
11 #include<algorithm>
12 #include<vector>
13 using namespace std;
14 typedef long long LL;
15 const int maxint = 0x7fffffff;
16 const long long max64 = 0x7fffffffffffffffll;
17 #define pr(x
) fprintf(stderr, x)
18 /* #define pr(x
) for(;0;) */
19 const int N = 128;
20 vector < int >g[N];
21 int dfn[N], n, vis[N], st[N], top;
22
23 void dfs(int u)
24 {
25 if (vis[u]) return;
26 vis[u] = true;
27 for (int i = 0; i < g[u].size(); i++) {
28 dfs(g[u][i]);
29 }
30 st[top++] = u;
31 }
32
33 int main()
34 {
35 int i, j, k, u, v;
36 scanf("%d", &n);
37 for (u = 1; u <= n; u++) {
38 while (1) {
39 scanf("%d", &v);
40 if (0 == v)
41 break;
42 g[u].push_back(v);
43 }
44 }
45 for (u = 1; u <= n; u++) {
46 if (!vis[u]) {
47 dfs(u);
48 }
49 }
50 for (i = top - 1; i > 0; i--) {
51 printf("%d ", st[i]);
52 }
53 printf("%d\n", st[i]);
54 return 0;
55 }
56
當(dāng)出現(xiàn)環(huán)時(shí),找入度為0的方法顯然當(dāng)不能找到入度為0的點(diǎn)時(shí)且還有剩余點(diǎn)則有環(huán)
利用dfs的方法就是找搜索樹種的回邊,利用染色的方法,算法導(dǎo)論上有介紹
我寫的代碼如下:
初始化:memset(vis,0,sizeof(vis));
對所有vis[i] == 0,調(diào)用dfs
bool dfs(int u)
{
if(vis[u] == 1) return false;
if(vis[u] == 2) return true;
vis[u] = 1;
for(i = 0;i < g[u].size();i++) {
if(false == dfs(g[u][i])) {
return false;
}
}
vis[u] = 2;
stack[top++] = u;
return true;
}
下圖描述了dfs的過程,建議仔細(xì)體會(huì)一下,求圖的割點(diǎn),橋,LCA的 tarjen算法主要過程基本和此dfs過程非常相似
圖中白色是還未訪問的,黑色是已經(jīng)完全訪問過的,藍(lán)色的是正在訪問的
又有好長時(shí)間沒寫了解題報(bào)告了,保研總算搞定了,月底去武漢,磨槍中....
1 /*
2 * SOUR:pku 1696
3 * ALGO:computional geometry
4 * DATE: Tue, 13 Oct 2009 10:42:25 +0800
5 * COMM:3
6 * 叉積點(diǎn)積轉(zhuǎn)啊轉(zhuǎn)啊
7 * */
8 #include<iostream>
9 #include<cstdio>
10 #include<cstdlib>
11 #include<cstring>
12 #include<algorithm>
13 #include<cmath>
14 using namespace std;
15 typedef long long LL;
16 const int maxint = 0x7fffffff;
17 const long long max64 = 0x7fffffffffffffffll;
18 #define pr(x
) fprintf(stderr, x)
19 /* #define pr(x
) for(;0;) */
20 const int N = 128;
21 struct point_t {
22 int x, y, idx;
23 point_t() {
24 } point_t(int a, int b) {
25 x = a, y = b;
26 }
27 } p[N], st[N];
28
29 bool vis[N];
30
31 #define sqr(x) ((x)*(x))
32 double dist(point_t a)
33 { return sqrt(sqr(a.x) + sqr(a.y)); }
34 double dist(point_t a, point_t b)
35 { return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y)); }
36
37 point_t operator +(point_t a, point_t b)
38 { return point_t(a.x + b.x, a.y + b.y); }
39 point_t operator -(point_t a, point_t b)
40 { return point_t(a.x - b.x, a.y - b.y); }
41
42 int cross_mul(point_t a, point_t b)
43 { return a.x * b.y - a.y * b.x; }
44 int cross_mul(point_t a, point_t b, point_t c)
45 { return cross_mul(a - c, b - c); }
46 int dot_mul(point_t a, point_t b)
47 { return a.x * b.x + a.y * b.y; }
48 int dot_mul(point_t a, point_t b, point_t c)
49 { return dot_mul(a - c, b - c); }
50
51 double angle(point_t a, point_t b)
52 {
53 double val = dot_mul(a, b);
54 val /= dist(a);
55 val /= dist(b);
56 return val;
57 }
58
59 int n, idx, top;
60 const int inf = (1 << 29);
61 void graham()
62 {
63 int i, j, k;
64 memset(vis, 0, sizeof(vis));
65 top = 2, st[0] = p[0], st[1] = p[1];
66 vis[0] = vis[1] = true;
67 for (i = 2; i <= n; i++) {
68 double val = -inf;
69 int idx;
70 for (j = 2; j <= n; j++) {
71 if (!vis[j]) {
72 int c = cross_mul(st[top - 1], p[j], st[top - 2]);
73 double d = angle(st[top - 1] - st[top - 2], p[j] - st[top - 1]);
74 if (c > 0) {
75 if ((d > val) || (d == val && dist(p[j], st[top - 1]) < dist(p[idx], st[top - 1]))) {
76 idx = j;
77 val = d;
78 }
79 }
80 }
81 }
82 if (val == -inf)
83 break;
84 st[top++] = p[idx], vis[idx] = true;
85 }
86 }
87
88 int main()
89 {
90 int i, j, k, testid;
91 scanf("%d", &testid);
92 while (testid-- > 0) {
93 scanf("%d", &n);
94 idx = 1;
95 scanf("%d%d%d", &p[1].idx, &p[1].x, &p[1].y);
96 for (i = 2; i <= n; i++) {
97 scanf("%d%d%d", &p[i].idx, &p[i].x, &p[i].y);
98 if ((p[i].y < p[idx].y) || (p[i].y == p[idx].y && p[i].x < p[idx].x)) {
99 idx = i;
100 }
101 }
102 swap(p[1], p[idx]);
103 p[0].idx = 0, p[0].x = 0, p[0].y = p[1].y;
104 graham();
105 printf("%d", top - 1);
106 for (i = 1; i < top - 1; i++) {
107 printf(" %d", st[i].idx);
108 }
109 printf(" %d\n", st[i].idx);
110 }
111 return 0;
112 }
113
國家集訓(xùn)隊(duì)2000論文集/方奇論文中的一題
1.dp ,算最小完成時(shí)間, 論文中貌似把max寫成min了。。
二分求最小完成時(shí)間亦可,而且更快,誰讓咱們看了論文了呢
for(i = 1;i <= n;i++) {
dp[1][i] = sum[1][i];
}
for(i = 2;i <= m;i++) {
for(j = 1;j <= n;j++) {
dp[i][j] = inf;
}
}
for(i = 2;i <= m;i++) {
for(j = i;j <= n;j++) {
for(k = 1;k < j;k++) { // 至少抄一本
int t = max( dp[i-1][k] , sum[k+1][j]);
if(dp[i][j] > t) {
dp[i][j] = min(dp[i][j] ,t);
}
}
}
}
2.從后向前推把更大的工作量留給后面的人,標(biāo)記'/'出現(xiàn)的位置
int limit = dp[m][n],sum,cnt;
pre[n] = 0,cnt = 1;
for(i = n-1,sum = num[n];i > 0;i--) {
if(sum + num[i] > limit) {
pre[i] = 1;
cnt ++;
sum = num[i];
}else {
pre[i] = 0;
sum += num[i];
}
}
3.如果'/'的數(shù)量小于題目給出的,從頭尋找第一個(gè)不是'/'的位置,標(biāo)記之
for(i = 1,j = cnt;j < m && i <= n;i++) {
if(pre[i] == 0) {
pre[i] = 1;
j++;
}
}
4.輸出
for(i = 1;i < n;i++) {
printf("%d ",num[i]);
if(pre[i])
printf("/ ");
}
printf("%d\n",num[i]);
注意:不要嘗試再dp轉(zhuǎn)移的時(shí)候標(biāo)記轉(zhuǎn)移方向,試圖得出標(biāo)記‘/’的位置,這個(gè)想法是錯(cuò)的,仔細(xì)想一下就知道了,
再不濟(jì)AC以后再試試
schindlerlee原創(chuàng),禁止轉(zhuǎn)載和用于商業(yè)用途
此題意思很明顯
把一個(gè)數(shù)從進(jìn)制a轉(zhuǎn)化到進(jìn)制b
用C/C++寫實(shí)在是太麻煩了,用java搞了一下,還是不熟啊,寫了好久
1 //java catalan 數(shù)
2 import java.math.*;
3 import java.util.*;
4 import java.io.*;
5
6 public class Main {
7
8 public static void main(String[] args) {
9 Scanner cin = new Scanner(
10 new BufferedReader(
11 new InputStreamReader(System.in)));
12 //That is (in decimal) A = 10, B = 11,
, Z = 35, a = 36, b = 37,
, z = 61
13 int c = cin.nextInt();
14 while (c-- > 0) {
15 int a = cin.nextInt();
16 int b = cin.nextInt();
17 BigInteger r = BigInteger.valueOf(0);
18 BigInteger idx = BigInteger.valueOf(1);
19 String s = cin.next();
20 System.out.println(a + " " + s);
21 for (int i = s.length() - 1; i >= 0; i--, idx = idx.multiply(BigInteger.valueOf(a))) {
22 char t = s.charAt(i);
23 //8 62 2 abcdefghiz System.out.println("char t = " + t);
24 int add;
25 if (t >= '0' && t <= '9') {
26 add = t - '0';
27 } else if (t >= 'A' && t <= 'Z') {
28 add = t - 'A' + 10;
29 } else {
30 add = t - 'a' + 36;
31 }
32 r = r.add(idx.multiply(BigInteger.valueOf(add)));
33 }
34
35 // System.out.println(r.toString());
36 String res = "";
37 idx = BigInteger.valueOf(b);
38 if (s.equals("0")) {
39 System.out.println(b + " 0");
40 } else {
41 while (r.compareTo(BigInteger.ZERO) > 0) {
42 BigInteger ad[];
43 ad = r.divideAndRemainder(idx);
44 r = ad[0];
45 int t = ad[1].intValue();
46 char ch;
47 if (t >= 0 && t <= 9) {
48 ch = (char) (t + '0');
49 } else if (t >= 10 && t <= 35) {
50 ch = (char) (t - 10 + 'A');
51 } else {
52 ch = (char) (t - 36 + 'a');
53 }
54 res = ch + res;
55 // System.out.println("ad[0]= "+ad[0]);
56 // System.out.println("ad[1]= "+ad[1]);
57 }
58 System.out.println(b + " " + res);
59 }
60 System.out.print('\n');
61 //System.out.println("res = "+res);
62 }
63 }
64 }
65
66
schindlerlee原創(chuàng),禁止轉(zhuǎn)載和用于商業(yè)用途
題目描述:
給定一個(gè)矩陣,找一個(gè)起始點(diǎn),由該點(diǎn)開始不斷馬跳,要求跳到的后一節(jié)點(diǎn)比前一節(jié)點(diǎn)的值大,問最多可以跳多少步,并且輸出跳躍的序列,如果兩個(gè)跳躍序列步數(shù)相同,給出字典序較小的
1 2 4
1 2 3
兩個(gè)序列當(dāng)然是后一個(gè)較小
第一感覺可以求出每個(gè)節(jié)點(diǎn)的跳躍序列,比較長度得出結(jié)果。但是我們發(fā)現(xiàn)其中有很多重復(fù)的路徑,由此想到dp。
本來此題如果只要求最長的跳躍步數(shù)的話,就是一道比較簡單的dp了。但是題目要求輸出最小的序列,需要稍微復(fù)雜一點(diǎn)的處理。
可以考慮為每個(gè)點(diǎn)增加一個(gè)pre坐標(biāo),指向前一個(gè)點(diǎn),但是這就帶來一個(gè)問題,要尋找最小的序列,如果有兩個(gè)相同長度的序列可供當(dāng)前點(diǎn)選擇的話,直接貪心是錯(cuò)誤的,下圖為反例

可以發(fā)現(xiàn),如果只比較前一點(diǎn)的話,左邊的路線是正確的,但是實(shí)際上右邊的是正確的。注意這一點(diǎn)基本就沒問題了。
1 /*
2 * SOUR:pku 2111
3 * ALGO:dp or search
4 * DATE: 2009年 08月 29日 星期六 04:16:26 CST
5 * COMM:
6 * */
7 #include<iostream>
8 #include<cstdio>
9 #include<cstdlib>
10 #include<cstring>
11 #include<algorithm>
12 using namespace std;
13 const int maxint = 0x7fffffff;
14 const long long max64 = 0x7fffffffffffffffll;
15 #define debug 1
16 const int N = 410;
17 int mov[8][2] = { {1, 2}, {2, 1}, {-1, 2}, {2, -1}, //
18 {1, -2}, {-2, 1}, {-1, -2}, {-2, -1}
19 };
20
21 int g[N][N], pre[N][N][2], n, dp[N][N], out[N], on;
22 struct L {
23 int x, y;
24 int val;
25 } query[N * N];
26 bool operator <(L a, L b)
27 {
28 return a.val < b.val;
29 }
30 int a[N*N],b[N*N];
31 bool judge(int tx,int ty,int px,int py)
32 {
33 int sp = 0,ta,tb,i;
34 while(tx != -1) {
35 a[sp] = g[tx][ty];
36 b[sp] = g[px][py];
37 sp ++;
38 ta = pre[tx][ty][0];
39 tb = pre[tx][ty][1];
40 tx = ta,ty = tb;
41
42 ta = pre[px][py][0];
43 tb = pre[px][py][1];
44 px = ta,py = tb;
45 }
46 for(i = sp - 1;i >= 0 && a[i] == b[i];i--);
47 if(a[i] < b[i])
48 return true;
49 return false;
50 }
51
52 int main()
53 {
54 int i, j, k, x, y, big, tx, ty;
55 scanf("%d", &n);
56 for (i = 0; i < n; i++) {
57 for (j = 0; j < n; j++) {
58 scanf("%d", &g[i][j]);
59 query[i * n + j].val = g[i][j];
60 query[i * n + j].x = i;
61 query[i * n + j].y = j;
62 pre[i][j][0] = pre[i][j][1] = -1;
63 }
64 }
65
66 sort(query, query + n * n);
67 for (i = 0; i < n * n; i++) {
68 x = query[i].x;
69 y = query[i].y;
70 for (j = 0; j < 8; j++) {
71 int tx = x + mov[j][0];
72 int ty = y + mov[j][1];
73 if (tx >= 0 && tx < n && ty >= 0 && ty < n
74 && g[x][y] > g[tx][ty]) {
75 if (dp[x][y] < dp[tx][ty] + 1) {
76 dp[x][y] = dp[tx][ty] + 1;
77 pre[x][y][0] = tx;
78 pre[x][y][1] = ty;
79 } else if (dp[x][y] == dp[tx][ty] + 1) {
80 int px = pre[x][y][0];
81 int py = pre[x][y][1];
82 if (judge(tx,ty,px,py)) {
83 pre[x][y][0] = tx;
84 pre[x][y][1] = ty;
85 }
86 }
87 }
88 }
89 }
90 on = 0, big = 0;
91 for (i = 0; i < n; i++) {
92 for (j = 0; j < n; j++) {
93 if (dp[i][j] > big) {
94 big = dp[i][j];
95 x = i, y = j;
96 }
97 }
98 }
99 while (x != -1 && y != -1) {
100 out[on++] = g[x][y];
101 tx = pre[x][y][0];
102 ty = pre[x][y][1];
103 x = tx, y = ty;
104 }
105 printf("%d\n", on);
106 for (i = on - 1; i >= 0; i--) {
107 printf("%d\n", out[i]);
108 }
109 return 0;
110 }
111
schindlerlee原創(chuàng),禁止轉(zhuǎn)載和用于商業(yè)用途
剛比賽完,先貼代碼
1 /*
2 * SOUR:pku 3744
3 * ALGO:compulicted
4 * DATE: 2009年 08月 23日 星期日 12:37:44 CST
5 * COMM:3
6 * */
7 #include<iostream>
8 #include<cstdio>
9 #include<cstdlib>
10 #include<cstring>
11 #include<algorithm>
12 using namespace std;
13 #define inf 0x7fffffff
14 #define debug 1
15 double p;
16 int mine[26], n;
17
18 struct M {
19 double v11, v12, v21, v22;
20 M operator*( M b)
21 {
22 M c;
23 c.v11 = v11 * b.v11 + v12 * b.v21;
24 c.v12 = v11 * b.v12 + v12 * b.v22;
25 c.v21 = v21 * b.v11 + v22 * b.v21;
26 c.v22 = v21 * b.v12 + v22 * b.v22;
27 return c;
28 }
29
30 M operator*( double c)
31 {
32 v11 *= c, v12 *= c;
33 v21 *= c, v22 *= c;
34 return *this;
35 }
36 } unit,self;
37
38
39 M f(int t)
40 {
41 if (t == 0) {
42 M a;
43 a.v11 = 1, a.v12 = 0;
44 a.v21 = 0, a.v22 = 1;
45 return a;
46 }
47 if (t == 1) {
48 return unit;
49 }
50 if (t % 2 == 0) {
51 M tmp = f(t / 2);
52 return tmp * tmp;
53 }
54 M tmp = f(t / 2);
55 return tmp * tmp * unit;
56 }
57
58 /*
59 f(n) { p ,1-p } f(n-1)
60 f(n-1) = { 1 , 0 } * f(n-2)
61 * */
62 int main()
63 {
64 int i, j;
65 while (scanf("%d %lf", &n, &p) == 2) {
66 unit.v11 = p, unit.v12 = 1 - p;
67 unit.v21 = 1, unit.v22 = 0;
68
69 self.v11 = 1, self.v12 = 0;
70 self.v21 = 0, self.v22 = 1;
71
72 bool flag = false;
73 for (i = 0; i < n; i++) {
74 scanf("%d", mine + i);
75 }
76 sort(mine, mine + n);
77 n = unique(mine, mine + n) - mine;
78 for (i = 1; i < n; i++) {
79 if (mine[i] - mine[i - 1] == 1) {
80 flag = true;
81 break;
82 }
83 }
84 if (flag || mine[0] == 1) {
85 printf("%.7f\n", 0.0);
86 continue;
87 }
88 int t = 1;
89 M res = self, tmp;
90 for (i = 0; i < n; i++) {
91 tmp = f(mine[i] - 1 - t);
92 t = mine[i] + 1;
93 res = res * tmp * (1 - p);
94 res.v12 = 0; //跳地雷
95 }
96 if(res.v11 <= 0) {
97 printf("%.7f\n", 0.0);
98 }else {
99 printf("%.7f\n", res.v11);
100 }
101 }
102 return 0;
103 }
104
很久沒更新了,題刷了不少,但是一直沒怎么總結(jié)先貼一篇
1 /*
2 * SOUR:pku 1451
3 * ALGO:trie
4 * DATE: 2009年 08月 17日 星期一 13:29:46 CST
5 * COMM:3
6 * */
7 #include<iostream>
8 #include<cstdio>
9 #include<cstdlib>
10 #include<cstring>
11 #include<algorithm>
12 using namespace std;
13 #define inf 0x7fffffff
14 #define debug 1
15 const int N = 1000 * 11;
16 int mov[10][5] =
17 { {-1}, {-1}, {0, 1, 2, -1}, {3, 4, 5, -1}, {6, 7, 8, -1}, {9, 10, 11, -1},
18 {12, 13, 14, -1}, {15, 16, 17, 18, -1}, {19, 20, 21, -1}, {22, 23, 24, 25, -1}
19 };
20
21 struct Trie {
22 int c;
23 Trie *next[26];
24 Trie() {
25 c = 0;
26 memset(next, 0, sizeof(next));
27 }
28 void insert(char *s, int f);
29 void getMax(char *s, int step, int len);
30 } *root, pool[N];
31 int pt;
32 void Trie::insert(char *s, int f)
33 {
34 c += f;
35 if (*s == 0)
36 return;
37 if (next[*s - 'a'] == NULL) {
38 next[*s - 'a'] = &pool[pt++];
39 }
40 next[*s - 'a']->insert(s + 1, f);
41 }
42
43 char tmp[61], res[61];
44 int freq;
45 void Trie::getMax(char *s, int step, int len)
46 {
47 if (step >= len) {
48 tmp[len] = 0;
49 if (c > freq) {
50 //strcpy(res, tmp);
51 for (int i = 0; i <= len; i++) {
52 res[i] = tmp[i];
53 }
54 freq = c;
55 }
56 return;
57 }
58
59 int idx;
60 for (int i = 0; mov[*s - '0'][i] >= 0; i++) {
61 idx = mov[*s - '0'][i];
62 if (next[idx] != NULL) {
63 tmp[step] = idx + 'a';
64 next[idx]->getMax(s + 1, step + 1, len);
65 }
66 }
67 }
68
69 int main()
70 {
71 int i, k, C, D, f;
72 char buf[30];
73 scanf("%d", &C);
74 for (k = 1; k <= C; k++) {
75 root = &pool[0];
76 pt = 1, memset(pool, 0, sizeof(pool));
77 printf("Scenario #%d:\n", k);
78 scanf("%d", &D);
79 while (D-- > 0) {
80 scanf("%s %d", buf, &f); //哥一開始buf開小了,報(bào)了stack smashing 。。。。。。。。
81 root->insert(buf, f);
82 }
83 scanf("%d", &D), getchar();
84 while (D-- > 0) {
85 scanf("%s", buf);
86 buf[strlen(buf) - 1] = 0;
87
88 int len = strlen(buf);
89 for (i = 1; i <= len; i++) {
90 freq = 0;
91 root->getMax(buf, 0, i);
92 if (freq > 0) {
93 printf("%s\n", res);
94 } else {
95 puts("MANUALLY");
96 }
97 }
98 printf("\n");
99 }
100 printf("\n");
101 }
102 return 0;
103 }
104
autocomplpop.vim
http://www.vim.org/scripts/script.php?script_id=1879
把omnicomplete 裝上,再裝上這個(gè),加上兩個(gè)不去分大小寫的選項(xiàng)
let g:AutoComplPop_IgnoreCaseOption=1
set ignorecase

哇,邊打字,邊補(bǔ)全
文本是schindlerlee原創(chuàng),查看原文請?jiān)L問
www.shnenglu.com/schindlerlee
轉(zhuǎn)載請保留此信息,本人保留關(guān)于本文的一切信息
const int PRECISION = 525;
const int SENTINAL = 0x7fffffff;
struct bignum {
int s[PRECISION];
int len;
void reset() {
for (int i = 0; i < PRECISION; i++) {
s[i] = SENTINAL;
} len = 0;
}
};
void justify(bignum & a, int step)
/*
* 調(diào)整乘法產(chǎn)生的結(jié)果
* 例如將:
*-------------------------------------------------------------
*| 64 | 64 |SENT|SENT|SENT|SENT|SENT|SENT|SENT|SENT|SENT|SENT|
*-------------------------------------------------------------
*調(diào)整為
*-------------------------------------------------------------
*| 4 | 0 | 7 |SENT|SENT|SENT|SENT|SENT|SENT|SENT|SENT|SENT|
*-------------------------------------------------------------
* */
{
if (step < PRECISION && a.s[step] != SENTINAL) {
if (a.s[step] > 9) {
if (a.s[step + 1] == SENTINAL)
a.s[step + 1] = 0;
a.s[step + 1] += a.s[step] / 10;
a.s[step] = a.s[step] % 10;
}
justify(a, step + 1);
} else {
a.len = step;
for (int i = step; i < PRECISION; i++) {
a.s[i] = SENTINAL;
}
}
}
void mul(bignum a, bignum b, bignum & c) //a b result
{
int i, j;
c.reset();
for (i = 0; i < a.len; i++) {
for (j = 0; j < b.len; j++) {
if(i+j < PRECISION) {
if (c.s[i + j] == SENTINAL) c.s[i + j] = 0;
c.s[i + j] += a.s[i] * b.s[j];
}
}
}
justify(c, 0);
}
看到網(wǎng)上寫的很多說裝pm-utils之類的。但是我的情況是,休眠以后系統(tǒng)根本就啟動(dòng)不了,直接黑屏在那里了。
也有人寫把主板電池扣下來放電,我是筆記本,也不太現(xiàn)實(shí)。
想進(jìn)windows試試,無意中發(fā)現(xiàn)grub菜單中有recovery mode ,選進(jìn)去,一切解決。。。。。。。。。。。
原來一切是如此簡單,反正我是重啟了n次。。。。
摘要: ubuntu下寫的,在linux shell可運(yùn)行 ,想編譯請安裝 libncurses5-dbg libncurses5-dev使用參數(shù) : g++ -lcurses snake.c 編譯方向鍵使用vim 默認(rèn)的hjkl進(jìn)行移動(dòng),可以熟悉vim的方向鍵菜單中 L 是確定 ,游戲中q是退出
Code highlighting produced by...
閱讀全文
切換使用emerald的主題
按alt-f2
執(zhí)行
emerald --replace
切換回原來的主題
按alt-f2
執(zhí)行
metacity --replace
在ubuntu把a(bǔ)pe文件轉(zhuǎn)換成mp3文件一直都是一個(gè)問題。
昨天第一次使用linux進(jìn)行這項(xiàng)工作,現(xiàn)在將方法記錄如下。
# 安裝soundconverter和mp3splt
# 使用soundconverter將ape文件轉(zhuǎn)換成一個(gè)mp3文件
# 使用mp3splt 分割生成的單個(gè)mp3文件
使用命令
mp3splt -c CDImage.cue -o @n.@t a.mp3
@n是音軌號
@t是音軌標(biāo)題
其中的信息都是根據(jù)CDImage.cue文件中來的。
還有其他參數(shù)可選,具體參見
man mp3splt
首先創(chuàng)建一個(gè)文件
寫入
#!/bin/sh
shutdown -h now
保存為power文件
之后
chmod +x power
之后就能使用定時(shí)關(guān)機(jī)了
但是需要有root權(quán)限才能關(guān)機(jī)
所以需要輸入的命令如下
sudo at 02:00 tomorrow -f power
之后使用
sudo atq
可以查選定時(shí)執(zhí)行的任務(wù)
sudo atrm
可以刪除已經(jīng)預(yù)定好的任務(wù)
indent是linux下一個(gè)能力極強(qiáng)的代碼整理軟件,使用他,可以輕松的寫出代碼風(fēng)格十分精良的代碼。
但是indent的參數(shù)太多,使用起來不是很容易,怎么辦呢?
查看
/usr/src/linux-headers-<版本>/scripts/Lindent
文件 ,可以看到一行代碼:
indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1
這一行就是linux內(nèi)核使用indent整理代碼的格式,使用這條命令就可以實(shí)現(xiàn)風(fēng)格十分良好的C或C++代碼
其中-l80是每一行最多80個(gè)字母,超出會(huì)拆行,如果不喜歡可以使用更長的行字?jǐn)?shù)