Time of Update: 2018-12-03
TabHost中的子Activity雖然是用Intent來啟動,但是實際上並沒有去啟動一個全新的Activity,這點可以從生命週期打log看出來。以下內容來自文章:http://www.eoeandroid.com/thread-72550-2-1.html1.把tabhost儲存為公有變數 public class AssistApplication extends Application { public static TabHost
Time of Update: 2018-12-03
protected void onAttachedToWindow() This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called beforeonDraw(android.graphics.Canvas), however it
Time of Update: 2018-12-03
以下摘自:《卓有成效的程式員》之自動化 我經常會一次往Subversion裡添加一批檔案。在使用命令列做這件事時,你必須指定所有想要添加的檔案名稱。如果檔案不多的話這還不算太糟糕,但如果你要添加20個檔案,那就費事了。當然你也可以用萬用字元,但這樣一來就可能匹配到已經在版本控制之下的檔案(這不會有什麼損害,只不過會輸出一堆錯誤資訊,可能會跟別的錯誤資訊混淆)。為瞭解決這個問題,我寫了一行簡單的bash命令: svn st | grep '^\?' | tr '^\?' ' ' |
Time of Update: 2018-12-03
這題有兩種方法,一種是用lcs來做,另外就是dp,不過其實現都差不多,記憶體方面還可以進一步最佳化,只開一個n的一維數就可以做這題時出現了一件怪事,點怪看代碼遞推式: c[i][j] = 0 i >= j; = c[i+1][j-1] si = sj; = min(c[i][j-1],c[i+1][j])+1 si!=
Time of Update: 2018-12-03
ViewPager 滑動速度設定,並實現點擊按鈕滑動 使用過ViewPager的童鞋,都會感覺到設定介面滑動挺簡單的。但是有時候卻滿足不了UI設計的要求。 在用這個ViewPager的時候我遇到兩個問題,不知道你們遇到沒有。這裡做個筆記,總結一下: 第一個問題是,ViewPager在我們滑動放手後,速度和動畫的變動率是固定的。 第二個問題的,我們再添加左右按鈕後,如點擊滑動到前一頁面(通過mViewPager.setCurrentItem(viewID,
Time of Update: 2018-12-03
使用以下代碼可以很好的完成同時分享圖片和文字的功能: private void share(String content, Uri uri){ Intent shareIntent = new Intent(Intent.ACTION_SEND); if(uri!=null){ shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/*");
Time of Update: 2018-12-03
這次還是想了很久,在床上時突然間想通了,不過寫得不是太慢了,寫代碼總是出現一些低級失誤,這雨真有點無語~~~~~ #include<stdio.h>#define N 100024struct node{ int l; int r; int sum;};node tree1[3*N];node tree2[3*N];int count[N];int count1[N];int arr[N];void buid_tree(node *p,int k,int left,int
Time of Update: 2018-12-03
//hdu1166 簡單線段樹#include <iostream>using namespace std;#define maxn 500004struct node{int left,right;int num;};node tree[3*maxn];int out=0;void build(int left,int right,int i){tree[i].left =left;tree[i].right =right;tree[i].num
Time of Update: 2018-12-03
演算法導論看得我真的很蛋疼,都怪自己平時看得書少,這題純粹是參考別人代碼得出來,自己還不是很明白 有一點想說的是,這裡並不需要維護父結點#include<iostream>#define N 105#define MAX 0x7fffffffusing namespace std;int n;int map[N][N];bool used[N];//int father[N];int dis[N];int Mst_prim(){int res = 0;for(int
Time of Update: 2018-12-03
當我知道,這代碼的長度時,我徹底無語了,這如果是比賽時這樣的題目做不出來,我想我會,倍受打擊,我想不到……………………………………………………………………………………………………
Time of Update: 2018-12-03
線段數塗色#include <iostream>#include <algorithm>using namespace std;#define maxn 100005struct node{int left,right;int color;}tree[maxn*4];bool visit[40];int sum;void build(int left,int right,int id){tree[id].left =left,tree[id].right
Time of Update: 2018-12-03
這題一看就知道是一道類比了,這次的goole code jam 竟有兩道類比,problem b也是不做不知道,一做才知道類比這麼煩,要考慮的細節還不少,這道題可調了我不少時間第二道更悲催~~~~怎麼做怎麼錯,雖然題意有點不是很明白,還是說回這題吧這題讓我學會了,在未搞清楚思路時千萬不要輕易動手寫代碼,不然調死你,代碼還要亂到要死,怎調都有問題,一開始就是這樣,後來果斷重寫,就過了^-^代碼:#include<iostream>#include<cmath>using
Time of Update: 2018-12-03
kruskal演算法就是在並查集基礎上加了個貪心,演算法正確性的證明看完演算法導論自己還不怎麼懂,不過感覺寫走來比起prim要來得順手得多#include<iostream>#include<vector>#include<algorithm>using namespace std;class node{public:int x;int y;int dis;};bool cmp(node& lhs,node&
Time of Update: 2018-12-03
/*1166 敵兵布陣*/#include<stdio.h>#include<string.h>#define N 50005struct node{ int l; int r; int sum;};node tree[3*N];//數大了,要開全域變數,不過有點矛盾,因為看了老師給的一本書說盡量不要用全域變數int num[N];//三個子函數都用到幾乎一樣的思想void buid_tree(node *pt,int *pn,int k,int
Time of Update: 2018-12-03
模板一:#include<iostream>using namespace std;int a[1000001],b[1000001],rr,tem,t,s;__int64 ans;void merg(int ll,int l,int r){rr=l-1,tem=ll,t=l,s=ll;while(ll<=rr&&t<=r)if(a[ll]<=a[t])b[tem++]=a[ll++];else {ans+=l-ll;b[tem++]=a[t++];
Time of Update: 2018-12-03
今天,省賽選撥,我才發現自己到底有多麼水,在珠海賽上有點讓我興奮過頭了,讓我看不清本來的我——(還是很水)。 不知道該如何訴說,“哎~~~~~~~~~~~~~~~~~~~~~~~~~~~~”可能是對我現在的心情最好的理解了 竟然一題不過,其中還有自己做過的!有點無言以對。 本來,沒有本來.... 如果,沒有如果.... 有的只是付出的收穫
Time of Update: 2018-12-03
//hdu1166 二維樹狀數組#include <iostream>using namespace std;int n;//int a[1025][1025];int c[1025][1025];int lowbit(int x){return x&(-x);}void insert(int x,int y,int value){while(y<=n){int
Time of Update: 2018-12-03
這次參加goole code jam 雖然一開始就沒想過要拿什麼獎,拿什麼T-shirt,不過這樣的結局也太令人無語了。 資格賽就無視了吧,基本參加的都可以過,我自認為自己還是有幾大希望進軍Rund 2 的說在三場Rund 1 中,第一場因為要參加華理工的邀請賽沒有做,這也就算了,悲奇的事就從第場開始了…………首先錯過第一場的我當然想在第二場過了,不再做第三場啦。那天晚上,我興高彩烈地寫完第一題代碼,正要編譯,才發現編譯器不行(在廣州,不是自己電腦,在網上找的個VC6 的綠色版)
Time of Update: 2018-12-03
很明顯,很水……………………………………其實就是nim Game 棋子的位置相當於石子的數量,m相當於有多少堆石子,走任意步就是說,可以從堆中任取多少石子#include<iostream>using namespace std;int main(){int m;while(cin >>m && m){int sum = 0;for(int i = 1;i <= m;i++){int x;cin >>x;sum ^= x;}if(sum)
Time of Update: 2018-12-03
水………………………………………………………………………………過,只不過是加個判斷和模板無分別#include<iostream>#include<string>#include<vector>using namespace std;string a,b;string Lcs(){vector<int> s(a.size(),0);string::size_type i = 1,j = 1;int flag = s[0]; int flag2 =